Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

是否支持动态添加dropzones #5

Closed
qq447665722 opened this issue Sep 18, 2017 · 2 comments
Closed

是否支持动态添加dropzones #5

qq447665722 opened this issue Sep 18, 2017 · 2 comments

Comments

@qq447665722
Copy link

尝试在example/nested.vue中添加

<div class="new-elements">
          <div class="panel panel--info">
            <div class="panel__heading">
              <h3>New Elements</h3>
            </div>
            <div class="panel__body">
              <vddl-draggable class="button"
                              :draggable="itemMock"
                              :copied="copied"
                              effect-allowed="copy">
                Add Item
              </vddl-draggable>
              <br>
              <vddl-draggable class="button"
                              :draggable="containerMock"
                              :copied="copied"
                              effect-allowed="copy">
                Add Container
              </vddl-draggable>
              <br>
              <a @click="dropzones.C=[]">Add Dropzone</a>
            </div>
          </div>
        </div>

添加<a @click="dropzones.C=[]">Add Dropzone</a>代码
点击Add Dropzone会出现奇怪的问题

  1. 视图中Dropzone没有即时出现,随便更改Container排序,新的Dropzone才会出现
  2. 拖动新的Container到新的Dropzone,视图并不能出现Container

是否我的使用方法有问题?

@hejianxian
Copy link
Owner

@qq447665722 谢谢使用!

我猜你的意思是,动态添加一个 Dropzone(而无需拖动)。如果只是单纯做这个东西,那么是没问题的,至于你这里为何不可以,是因为<a @click="dropzones.C=[]">Add Dropzone</a>这样写并不能让 Vue 更新视图,你可以试试使用 Object.assign方法添加新的属性:

this.dropzones = Object.assign({}, this.dropzones, {
    C: []
});

@qq447665722
Copy link
Author

明白,谢谢~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants