记录使用 vue 遇到的一些问题

1. vue component 中的 asset url 若是想用webpack 配置的 alias 须要在前面加 ~ ,例如

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 and css-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. webpack

For example, url(./image.png) will be translated into require('./image.png')git

感受说的有点乱,总结就是 template, style 须要加 ~, script 里面的不须要加 ~github

2. IE 11 下 webpack中使用 echart 报错,其余浏览器正常

问题描述: 在利用 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)浏览器

3. IE 11 下 连接没法跳转

问题描述: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>
相关文章
相关标签/搜索