alias: { 'assets': path.resolve(__dirname, '../src/assets') }
<template> <div id="app"> <img class="logo" src="~assets/logo.png">
<script> import img from "assets/logo.png" </script>
根据 这个isssue 的描述是css
vue-html-loader
andcss-loader
translates non-root URLs to relative paths. In order to treat it like a module path, prefix it with ~:html
根据 文档 的描述是vue
By default, vue-loader automatically processes your style and template files with css-loader and the Vue template compiler. In this compilation process, all asset URLs such as
<img src="...">
,background: url(...)
and CSS@import
are resolved as module dependencies. webpackFor example,
url(./image.png)
will be translated intorequire('./image.png')
git
感受说的有点乱,总结就是 template, style 须要加 ~, script 里面的不须要加 ~github
问题描述: 在利用 vue-cli 搭建的环境中, 引入 echart 会发生echart TypeError: 调用的对象无效
的错误
问题讨论: https://github.com/ecomfe/zre...web
若是你是在 webpack 中使用 echarts,则 webpack 的 config 中 devtool 设置为含有eval时,能够重现该问题vue-cli
解决方案:把 devtool 设置为不含有eval的方式, 好比 cheap-source-map
(vue-cli 默认生成的开发配置是cheap-eval-source-map
)浏览器
问题描述:app
<el-button type="primary"> <router-link to="/login">登陆</router-link> </el-button>
解决方法: 把 <router-link>
放到外层
<router-link to="/login"> <el-button type="primary">登陆</el-button> </router-link>