NaiveUi组件库遇到的问题
- Upload组件 在使用上传文件组件时,无论怎么写控制台都会出现Vue warn
js
[Vue warn]: Extraneous non-props attributes (mode) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.
解决
js
//暂时还不知道原因,解决办法是再GitHub lssuse中查到,给upload组件添加prop `showFileList={false}`
<NUpload showFileList={false} ></NUpload>
2.Tree组件 在使用tree组件时,当组件的数据childre字段为空数组时,tree组件仍然会渲染展开箭头,查看github Issuse后发现,官方说这个是预期行为,没有数据和children为空是两个行为 解决
js
//https://github.com/tusen-ai/naive-ui/pull/4255
为tree组件添加:get-children="getTreeChildren"属性
const getTreeChildren = (tree: TreeOption) => {
if (tree.children && tree.children.length > 0) return tree.children;
};
//这样就能解决箭头显示问题