我是 vue.js 的新手,在此之前我在我的项目中使用 jquery 或 js,我正在开发一个项目,该项目要求我在按钮单击时动态附加 HTML 元素,同时绑定输入值建模,类似于:
$(".button").click(function() {
$("#target").append("<input type='hidden' name='data' v-model='inputModel' value='1'/>");
});
Run Code Online (Sandbox Code Playgroud)
但我需要 Vue.js 的方式。
这是我的代码:
data() {
return {
programmeBanner: [],
dropzoneOptions: {
...
...
init: function () {
this.on("success", function(file, response) {
file.previewElement.id = response;
// this is the part that i want to append the html input into
// the .dz-preview is the target that i want to append
$(".dz-preview[id='"+response+"']").append("<input type='hidden' name='"+fileInputName+"[]' v-model='programmeBanner' class='"+fileInputName+"' value='"+response+"'/>");
});
},
...
Run Code Online (Sandbox Code Playgroud)
这是我想要实现的示例,这是在 Jquery 中,我在 Vue.js 中需要它 …