【问题标题】:How to use v-model and other js plugins in the same select如何在同一个select中使用v-model和其他js插件
【发布时间】:2017-09-26 07:15:16
【问题描述】:

我在我的项目中使用 jquery select2datepicker 插件。我为他们使用了自定义指令。在我需要使用v-model 获取所选值之前,它们工作正常。由于某种原因,它不绑定该值。我的猜测是某处发生了冲突。

这是我的指令:

Vue.directive('select', {
    twoWay: true,
    inserted: function (el) {
        $(el).select2();
    },
    updated: function (el) {
        $(el).select2();
    }
});

更新功能不起作用。但是 inserted 有效。

如何获取选中的值?

【问题讨论】:

标签: javascript vue.js jquery-ui-datepicker jquery-select2 vuejs2


【解决方案1】:

https://vuejs.org/v2/guide/migration.html#twoWay-Prop-Option-removed

twoWay 道具选项已删除

道具现在总是单向下降。产生副作用 父作用域,组件需要显式发出事件而不是 依赖于隐式绑定。

您需要写一个wrapper component。碰巧,这个例子是针对 select2 的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-14
    • 2020-05-01
    • 1970-01-01
    • 2019-12-16
    • 2020-07-01
    • 1970-01-01
    • 2019-05-13
    • 2021-05-26
    相关资源
    最近更新 更多