vue开发问题总结

一、报错提示:This dependency was not found:

  • /components/Lianxi.vue in ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/App.vue To install it, you can run: npm install --save /components/Lianxi.vue

出错地方:import HelloWorld from '@components/HelloWorld'

原因:在@符号后面少了/

正确写法:import HelloWorld from '@/components/HelloWorld'


二、错误:浏览器中vue渲染空白

调试:提示ReferenceError: Demo is not defined

原因:下面的name值没有加单引号

<script>
export default {
    name: ddd,
    data(){
    }
}
</script>

三、错误:浏览器地址变了,页面不跳转

原因:路由没有使用history模式

export default new Router({
  mode: 'history',
  routes: [
    {
      path: '/',
      name: 'ddd',
      component: ddd
    },
    {
      path: '/hello',
      name: 'HelloWorld',
      component: HelloWorld
    }
  ]
})

两种模式都可以跳转,只是URL不同:
hash模式:http://localhost:8080/#/hello#/
history模式:http://localhost:8080/hello
--使用hash模式多了#号

分析:vue-router 默认 hash 模式 —— 使用 URL 的 hash 来模拟一个完整的 URL,于是当 URL 改变时,页面不会重新加载。

当你使用 history 模式时,URL 就像正常的 url,例如 http://yoursite.com/user/id

  1. hash —— 即地址栏 URL 中的 # 符号(此 hash 不是密码学里的散列运算)。比如这个 URL:http://www.abc.com/#/hello,hash 的值为 #/hello。它的特点在于:hash 虽然出现在 URL 中,“#”后面的内容不会被包括在 HTTP 请求中,对后端完全没有影响,因此改变 hash 不会重新加载页面。
  1. history —— 利用了 HTML5 History Interface 中新增的 pushState() 和 replaceState() 方法。(需要特定浏览器支持)这两个方法应用于浏览器的历史记录栈,在当前已有的 backforwardgo 的基础之上,它们提供了对历史记录进行修改的功能。只是当它们执行修改时,虽然改变了当前的 URL,但浏览器不会立即向后端发送请求。

四、问题:使用element ui框架元素没起作用

原因:没有安装element ui框架和引用element ui

安装过程:
第一步:npm i element-ui -S
第二步:在main.js中引入js和css
	import ElementUI from 'element-ui'
	import 'element-ui/lib/theme-chalk/index.css'
第三步:Vue.use(ElementUI)

五、前后端分离项目,跨域请求报错

Access to XMLHttpRequest at 'http://localhost:8080/api/user/login' from origin 'http://localhost:8080

解决方法一:在后端启动类中加入下面代码

public CorsConfiguration buildConfig() {
        CorsConfiguration corsConfiguration = new CorsConfiguration();
        corsConfiguration.addAllowedOrigin("*"); // 1允许任何域名使用
        corsConfiguration.addAllowedHeader("*"); // 2允许任何头
        corsConfiguration.addAllowedMethod("*"); // 3允许任何方法(post、get等)
        return corsConfiguration;
    }

    @Bean
    public CorsFilter corsFilter() {
        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
        source.registerCorsConfiguration("/**", buildConfig()); // 4
        return new CorsFilter(source);
    }

解决方法二:在Controller类上加@CrossOrigin注解

六、问题:vue前端上传文件后,后端报空指针异常

原因:没有在controller方法参数MultipartFile加@RequestParam("file")
@RequestMapping("/upload")
    public void taxiInfoImport(@RequestParam("file") MultipartFile taxiInfoFile){
        try {
            byte[] bytes = taxiInfoFile.getBytes();
            System.out.println(bytes.length);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

七、问题:编译报错 !!vue-style-loader!css-loader?{"sourceMap":true}!../..

错误信息:
* !!vue-style-loader!css-loader?{"sourceMap":true}!../../node_modules/vue-loader/lib/style-compiler/index?{"vue":true,"id":"data-v-f17233f8","scoped":true,"hasInlineConfig":false}!sass-loader?{"sourceMap":true}!../../node_modules/vue-loader/lib/selector?type=styles&index=1!./Temp.vue in ./src/components/Temp.vue
To install it, you can run: npm install --save !!vue-style-loader!css-loader?{"sourceMap":true}!../../node_modules/vue-loader/lib/style-compiler/index?{"vue":true,"id":"data-v-f17233f8","scoped":true,"hasInlineConfig":false}!sass-loader?{"sourceMap":true}!../../node_modules/vue-loader/lib/selector?type=styles&index=1!./Temp.vue

解决方法:npm install -g npm

八、element-ui动态表头,表头内容无法显示

错误原因::label="item.lable",其中lable属性拼写错误!!!
<el-table-column :prop="item.prop" :label="item.lable"></el-table-column>

问题:this.axios.get报错,Error in mounted hook: "ReferenceError: axios is not defined"

 

解决方法:this.axios.get改为this.$axios.get

九、问题:vue中如何添加对象属性和动态更新data中的数据?

定义一个对象:var compInfo = {};
合并对象:var cmp = Object.assign(compInfo, compItm);
在method中动态添加数据:this.tableData = this.tableData.concat([cmp]);

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Vue开发Chrome插件需要以下几个步骤: 1. 创建一个Vue项目:首先需要安装Vue CLI来创建一个新的Vue项目。在命令行中运行如下命令来创建项目: ``` vue create chrome-extension-project ``` 根据提示选择需要的配置项,如Babel和Router。创建完成后,进入项目目录: ``` cd chrome-extension-project ``` 2. 配置Chrome插件:在项目根目录下创建一个`manifest.json`文件,该文件用于配置插件的基本信息,例如插件名称、描述、图标、权限等。详细的配置可以参考Chrome官方文档。 3. 开发Vue组件:使用Vue开发插件的界面。可以在`src`目录下创建Vue组件,并在需要的地方使用它们。可以使用Vue Router来管理插件的不同页面或者使用Vuex来处理全局状态。 4. 构建插件:在命令行中运行如下命令来构建插件: ``` npm run build ``` 该命令会将Vue项目打包成一组静态文件,可以在`dist`目录中找到构建好的插件文件。 5. 导入插件:在Chrome浏览器中打开扩展程序页面(在地址栏输入`chrome://extensions`),点击右上角的“开发者模式”,然后点击“加载已解压的扩展程序”,选择之前构建好的插件文件夹(即`dist`目录)。 6. 调试和发布:在Chrome浏览器中调试已加载的插件,可以通过“检查视图”来调试Vue组件。如果插件开发完成并通过测试,可以在Chrome Web Store上发布插件,供用户下载和使用。 总结起来,Vue开发Chrome插件的过程可以概括为:创建Vue项目,配置插件信息,开发Vue组件,构建插件文件,导入插件到Chrome浏览器,调试并最终发布。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值