Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
143
rated 0 times [  144] [ 1]  / answers: 1 / hits: 66547  / 6 Years ago, wed, august 22, 2018, 12:00:00

I am using Vue-Cli3.0. I used this module for Vue.js. https://github.com/holiber/sl-vue-tree



This is a customizable draggable tree component for Vue.js but I found that it could not copy functions of object.



https://github.com/holiber/sl-vue-tree/blob/master/src/sl-vue-tree.js#L715



Because of here.



JSON.parse(JSON.stringify(entity))


So I used this module and edited the copy function.



https://www.npmjs.com/package/clone



var clone = require('clone');

copy(entity) {
return clone(entity)
},


In this way, the function of the object is correctly copied.



I already have tested it, and it worked correctly. There was no problem with the performance but I got a console error.



[Vue warn]: Invalid default value for prop multiselectKey: Props with type Object/Array must use a factory function to return the default value.

found in

---> <SlVueTree>


I want to know the way to erase this error.
Thank you for reading my question.


More From » typescript

 Answers
53

according to your console warn, i find the error



https://github.com/holiber/sl-vue-tree/blob/master/src/sl-vue-tree.js#L30



try to fix it like this:



multiselectKey: {
type: [String, Array],
default: function () {
return ['ctrlKey', 'metaKey']
},
validator: function (value) {
let allowedKeys = ['ctrlKey', 'metaKey', 'altKey'];
let multiselectKeys = Array.isArray(value) ? value : [value];
multiselectKeys = multiselectKeys.filter(keyName => allowedKeys.indexOf(keyName ) !== -1);
return !!multiselectKeys.length;
}
},


the component default value must use a factory function to return!



try it and hope it can help you


[#53678] Saturday, August 18, 2018, 6 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
harleedayanarar

Total Points: 303
Total Questions: 90
Total Answers: 102

Location: Virgin Islands (U.S.)
Member since Tue, Jul 7, 2020
4 Years ago
;