vue里外部控制组件wangeditor的高度

本文介绍了在Vue项目中如何从外部控制wangeditor编辑器的高度,包括组件内部的实现细节和页面引入wangeditor的相关代码示例。
摘要由CSDN通过智能技术生成

vue里外部控制组件wangeditor的高度

组件内部

<template>
	  <div>
	      <div :id="id" :style="'height:'+height+'px'"></div>
	  </div>
</template>
export default {
  components: {},
  props: {
    content: String,
    id:String,
    height:{    //传入高度
      type:Number,
      default:200
      }
  },
<style lang='scss' >
.w-e-text,.w-e-text-container{
  height: inherit !important;             //继承一下就可以了
  min-height: 0 !important;
}
.w-e-text{
  overflow-y: scroll;                //隐藏底部滑块
}
</style>

引入组件

          <wang-edit
              :height="105"
              :id="div1"
              @getContent="getContentdescription"
              :content="thirdtext"
          ></wang-edit>
</
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Vue 3中,函数式组件可以通过Vue-wangeditor组件来集成wangEditor编辑器。以下是在Vue 3函数式组件中添加自定义内容的步骤: 1. 在Vue-wangeditor组件中引入wangEditor编辑器。在setup函数中定义一个ref来引用编辑器实例。 ``` <template> <div> <vue-wangeditor v-model="content" :config="editorConfig" ref="editor"></vue-wangeditor> </div> </template> <script> import VueWangEditor from 'vue-wangeditor'; import wangEditor from 'wangeditor'; export default { components: { VueWangEditor, }, setup() { const editorRef = Vue.ref(null); const editorConfig = { // 在这配置编辑器 }; return { editorRef, editorConfig, }; }, }; </script> ``` 2. 在editorConfig中添加自定义菜单。在菜单的click属性中,指定要执行的函数。例如,你可以添加一个名为“自定义菜单”的菜单,并将其单击事件绑定到myCustomFunction函数。 ``` const editorConfig = { menus: [ 'head', 'bold', 'italic', 'underline', 'strikeThrough', 'foreColor', 'backColor', 'link', 'list', 'justify', 'quote', 'emoticon', 'image', 'table', 'video', 'code', 'undo', 'redo', 'fullscreen', 'customMenu' ], customMenu: { title: '自定义菜单', type: 'click', click: () => { myCustomFunction(editorRef); } } }, ``` 3. 在myCustomFunction函数中添加自定义的代码。例如,你可以在函数中插入一个文本片段。 ``` function myCustomFunction(editorRef) { // 在光标处插入文本片段 editorRef.value.$editor.command(null, 'insertHtml', '这是一段自定义内容'); } ``` 这样就可以在Vue 3函数式组件中添加自定义内容了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值