vue.js - 如何在 vue-quill 编辑器中发出多个参数?
问题描述
我正在使用 vue-quill 编辑器并尝试将其与自定义组件一起使用。这是我的代码。
所见即所得输入.vue
<template>
<div class="my-3">
<quill-editor
:options="{
placeholder: placeholder,
}"
v-on:change="($event) => $emit('change', $event.text)"
></quill-editor>
</div>
</template>
创建.vue
<wysiwyg-input @change="setField" placeholder="Post Content" />
我想用一个额外的参数来访问 quill-editor 的值,就像这样。
<wysiwyg-input @change="setField($event.text, 'content')" placeholder="Post Content" />
那么在 WysiwygInput.vue 上要改变什么?谢谢是提前。
Codesandbox 链接: https ://codesandbox.io/s/mystifying-benz-w8wgu?file=/src/FormFields.vue
解决方案
您可以使用方法发出许多参数$emit
:
v-on:change="($event) => $emit('change', $event.text,param2,param3)"
并在父组件中添加处理程序,如:
<wysiwyg-input @change="setField" placeholder="Post Content" />
...
setField(text,param2,param3){
...
}
如果你想在父组件中添加参数到发出的事件处理程序,你应该添加内联处理程序,如:
<wysiwyg-input @change="(text)=>setField(text, 'content')" placeholder="Post Content" />
推荐阅读
- python - ValueError:操作数无法与形状一起广播 (2501,201) (2501,)
- testng - 从 appium java 客户端 5.04 升级到 6.0.1 后无法运行 testngsuite
- c# - DevExpress:XtraReport 中缺少标签
- php - whois/testwhois.php 404 错误
- teradata - Teradata 性能因计数不同而受到影响
- android - 如何控制从一个用户到另一个用户的共享帐户?
- java - 使用spring MVC将文件夹上传到mysql时出错
- python - 无法将 pip3 与 sudo 一起使用
- ip - 就服务器而言,IP 地址 127.0.0.1 如何使用?
- angularjs - 未在 JSFiddle 中调用的函数