inleft
2022-08-26 87317f44d9cc20ad70b6971168667e1c843e03d8
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>
937681 8         <div ref="container" class="OwO fadeIn" v-show="init"></div>
c14e32 9     </div>
I 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) {
937681 31                     if (!this.init) {
c14e32 32                         this.showTip = true;
I 33                         setTimeout(() => {
34                             this.showTip = false;
35                         }, 5000);
36                     }
937681 37                     this.init = true;
I 38                     this.initOwO();
c14e32 39                 }
I 40                 this.$emit("update:content", newValue)
41             },
42         },
43         methods: {
937681 44
c14e32 45             initOwO() {
I 46                 var OwO_demo = new OwO({
47                     logo: 'OωO表情',
48                     // container: document.getElementsByClassName('OwO')[0],
49                     // target: document.getElementsByClassName('OwO-textarea')[0],
50                     container: this.$refs.container,
51                     target: this.$refs.targetArea.$el,
52                     // api: './OwO.json',
53                     // api: 'http://diygod.github.io/OwO/demo/OwO.json',
54                     jsonText: OwOjsonConfig,
55                     position: 'down',
56                     width: '100%',
57                     maxHeight: '250px'
58                 });
59             }
60         }
61     }
62 </script>
63
64 <style>
65
66 </style>