Answer the question
In order to leave comments, you need to log in
How to properly comment Vue code?
For example, there is a code:
...
props: {
items: {
validator(items) {
function isValid() {
if (Array.isArray(items) !== true) return false;
return items.every((item) => {
if (typeof item !== 'object' || item.constructor !== Object) return false;
if (typeof item.id !== 'string') return false;
if (typeof item.title !== 'string') return false;
if (typeof item.sub !== 'object' || item.sub.constructor !== Object) return true;
return isValid(item.sub);
});
}
return isValid(items);
},
required: false,
},
},
...
/**
* @param {object[]} items
* @param {string} items[].id
* @param {string} items[].name
* @param {object[]} items[].sub
* @param {string} items[].sub[].id
* @param {string} items[].sub[].name
*/
/**
* @vue-prop {object[]} items
* @vue-prop {string} items[].id
* @vue-prop {string} items[].name
* @vue-prop {object[]} items[].sub
* @vue-prop {string} items[].sub[].id
* @vue-prop {string} items[].sub[].name
*/
Answer the question
In order to leave comments, you need to log in
Use typescript + https://github.com/vuejs/vue-class-component
Out of the box with typing and documentation in vue is sad.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question