V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
ioioioioioioi
V2EX  ›  问与答

Vue.js Summernote.js component 如何使 v-if 工作? 这个插件,在一个页面会调用多次,希望只显示 model 有内容的

  •  1
     
  •   ioioioioioioi · 2018-06-20 16:29:16 +08:00 · 933 次点击
    这是一个创建于 2135 天前的主题,其中的信息可能已经有所发展或是发生改变。
    <!-- Reference: https://github.com/StefanNeuser/vuejs2-summernote-component/blob/master/src/Summernote.js -->
    <template>
    <textarea v-if="model" :name="name">{{ model }}</textarea>
    </template>
    <script>
        module.exports = {
            props: {
                model: {
                    required: true,
                },
    
                name: {
                    type: String,
                },
    
                height: {
                    default: '400'
                }
            },
            mounted() {
    
                let config = {
                    height: this.height
                };
    
                let vm = this;
    
                config.callbacks = {
    
                    onInit: function () {
                        $(vm.$el).summernote("code", vm.model);
                    },
    
                    onChange: function () {
                        vm.$emit('update:model', $(vm.$el).summernote('code'));
                    },
    
                    onBlur: function () {
                        vm.$emit('update:model', $(vm.$el).summernote('code'));
                    }
                };
    
                $(this.$el).summernote(config);
            }
        }
    </script>
    
    <style scoped>
    </style>
    
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1253 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 17:59 · PVG 01:59 · LAX 10:59 · JFK 13:59
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.