小编Blu*_*Ycw的帖子

如何在 Vue.js 中动态地将 HTML 元素附加到组件

我是 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 中需要它 …

html append vue.js

3
推荐指数
1
解决办法
1万
查看次数

无论如何有没有使canvas对象自动对齐对齐Fabric.js

我正在构建一个编辑器的项目中,我正在使用Fabric.js,但我不知道如何使canvas对象自动对齐。

是否有使画布对象与其他对象自动对齐的示例?来自其他站点

的快照示例
自动快照示例的 图像

链接在此处:
快照示例站点

fabricjs

2
推荐指数
1
解决办法
1283
查看次数

标签 统计

append ×1

fabricjs ×1

html ×1

vue.js ×1