我试图实现一个Vue组件,我收到错误:
[Vue warn]: Error in render: "TypeError: Cannot set property props of
#
我也在使用vuedraggable库,但我认为问题更多的是Vue问题,而不是vuedraggable问题.以下是我的代码.
这是draggable-list.vue
可拖动,list.js
const draggable = require("vuedraggable");
module.exports = {
name: "draggable-list",components: {
draggable
},// properties which has been passed from the parent vue to the component
props: ["title","elements"],data() {
return {
isDragging: false,};
},methods: {
test() {
console.log("blou");
}
}
};
draggable-list-component.html:
require("./components/manager");
在经理中我实例化了我的Vue实例:
const Vue = require("vue/dist/vue.common");
const draggableList = require("./draggable-list.vue");
let triggerLibrary;
triggerLibrary = new Vue({
el: "#draggable-list",template: "
我在我的index.html中使用它像这样:
Meta charset="utf-8">
<Meta name="viewport" content="width=device-width,initial-scale=1.0">
有谁看到这里有什么问题?
最佳答案
当您使用CommonJS模块时,尝试以这种方式要求您的Vue组件:
const draggableList = require("./draggable-list.vue").default;