V2EX › 问与答
Vue.js Summernote.js component 如何使 v-if 工作? 这个插件,在一个页面会调用多次,希望只显示 model 有内容的
By ioioioioioioi at 2018 年 6 月 20 日 · 1582 次点击<!-- 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>
目前尚无回复