inleft
2022-08-16 c14e3278893b9dd1022aa488cee53a888c2a4c7e
commit | author | age
c14e32 1 <template>
I 2     <div id="area">
3         <a-form-item>
4             <a-textarea ref="targetArea" :rows="4" v-model="visitorContent" :placeholder="this.$attrs.replyHolder"
5                 class="OwO-textarea" />
6         </a-form-item>
7         <span class="myTip fadeIn" v-if="showTip">现在你可以发送表情啦</span>
8         <div ref="container" class="OwO fadeIn" v-show="init || visitorContent.length>0"></div>
9     </div>
10 </template>
11
12 <script>
13     import 'owo/dist/OwO.min.css';
14     import OWO from '../../js/myOwO.js'
15     import OwOjsonConfig from '../../assets/OwO.json'
16
17     export default {
18         props: {
19             content: String
20         },
21         data() {
22             return {
23                 init: false,
24                 showTip: false,
25                 visitorContent: '',
26             }
27         },
28         watch: {
29             visitorContent: function(newValue, oldValue) {
30                 if (newValue.length > 0) {
31                     this.init = true;
32                     this.initOwO();
33                     if (!this.showTip) {
34                         this.showTip = true;
35                         setTimeout(() => {
36                             this.showTip = false;
37                         }, 5000);
38                     }
39                 }
40                 this.$emit("update:content", newValue)
41             },
42         },
43         methods: {
44             initOwO() {
45                 var OwO_demo = new OwO({
46                     logo: 'OωO表情',
47                     // container: document.getElementsByClassName('OwO')[0],
48                     // target: document.getElementsByClassName('OwO-textarea')[0],
49                     container: this.$refs.container,
50                     target: this.$refs.targetArea.$el,
51                     // api: './OwO.json',
52                     // api: 'http://diygod.github.io/OwO/demo/OwO.json',
53                     jsonText: OwOjsonConfig,
54                     position: 'down',
55                     width: '100%',
56                     maxHeight: '250px'
57                 });
58             }
59         }
60     }
61 </script>
62
63 <style>
64
65 </style>