JavaScript/vue.js/error
来自康健生活
< JavaScript | vue.js
标题文字
- Cannot assign to read only property 'exports' of object '#<Object>'
- js 可以混用 require、export。但是不能混用import、module.exports
- Unknown custom element: <el-menu> - did you register the component correctly
- 没有引用 element-ui
import ElementUI from 'element-ui'; //element-ui的全部组件 Vue.use(ElementUI); //使用elementUI
- Invalid prop: type check failed for prop "collapseTransition". Expected Boolean, got String with value "false".
- 类型错误,加
:即可 :collapse-transition="false"
- 类型错误,加
- TypeError: Cannot read property 'openedMenus' of undefined,在使用 elementui 时出现错误,按需子组件 vue 页面加载即可
import {Menu, Submenu, MenuItem, MenuItemGroup} from 'element-ui'; Vue.use(Menu); Vue.use(Submenu); Vue.use(MenuItem); Vue.use(MenuItemGroup);
- Unknown custom element: <el-menu> - did you register the component correctly? For recursive components, make sure to provide the "name" option
- 耗时 5 个小时,试过多个 webpack 方案,经过仔细爬坑,是因为 vue 与 ejs 不兼容导致的(vue-loader 与 html-webpack-plugin 和 ejs-compiled-loader),将 ejs 解析器 替换回 ejs-loader(vue-loader 与 html-webpack-plugin 和 ejs-loader)即可,但是这样就不能使用 ejs 嵌套标签
- 更正,并不是 (vue-loader 与 html-webpack-plugin 和 ejs-compiled-loader)不兼容,而是重复引入多个 elementui 导致错误
- Do not use built-in or reserved HTML elements as component id: Header
- 模板插入到 DOM 中的标签名须能够被 DOM 正确地解析需要避免完全不合法的标签名
- vue.esm.js:628 [Vue warn]: Failed to mount component: template or render function not defined.found in---> <Anonymous> <App> at view/index/app.vue <Root>
- 路由文件里面改 import Vue from 'vue'; 为
import Vue from 'vue/dist/vue.common.js';
- 路由文件里面改 import Vue from 'vue'; 为
- <router-view> 内容不渲染问题
<router-view class="index" name="NavMenu"></router-view>改为<router-view></router-view>,如果一定使用 name(路由命名),name 要与 router.js 内的组件名称一致,是components而不是component。export default new Router({ routes: [ { path: '/', components: {NavMenu: NavMenu}, children:[] } ] })
- [Vue warn]: Invalid prop: type check failed for prop "index". Expected String, got Number.
- 使用强制类型转换技巧
<el-submenu :index="item.id+">转换数据类型
- 使用强制类型转换技巧
- css 样式抽取极其不稳定,只显示
/*# sourceMappingURL=index_page_script.css.map*/。现在遇到的问题是 MiniCssExtractPlugin.loader 可以提取 css 文件打包使用 link 标签插入,或者 vue-style-loader 抽离 vue 文件中的 css 用 style 标签插入
其中 FixStyleOnlyEntriesPlugin 组件一定要与 MiniCssExtractPlugin 同步使用,不然会把 css 的 js 文件删除,导致 css 文件无法插入文本。
- elementui 更改样式无效,修改 css 标签,去掉 scoped
<style lang="scss" rel="stylesheet/scss" scoped>
- Component template should contain exactly one root element. If you are using v-if on multiple elements, use v-else-if to chain them instead
<template> <div> <router-view name="default"></router-view> <router-view name="index_main"></router-view> <router-view name="info_main"></router-view> <router-view name="list_main"></router-view> </div> </template>
- Vue warn]: Error in render: "TypeError: Cannot read property 'key' of undefi
- 元素加上v-if 指令,判断这个数组中是否有内容,警告即可解除
No categories