Vue常见问题及处理

栏目: 编程语言 · 发布时间: 7年前

内容简介:解决方案:在最外边 包上一个容器(不允许直接返回多个元素)vue.js:435 [Vue warn]: Unknown custom element: <my-footer> - did you register the component correctly? For recursive components, make sure to provide the "name" option.原因:你把局部组件当成全局组件去使用了
  1. vue.js 2.0要求每个template只能有一个根元素。可以在最外层包一个div来解决这个问题。

vue.js:435 [Vue warn]: Error compiling template:

<h2>这是页头</h2>
        <button>登录</button>

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.

解决方案:在最外边 包上一个容器(不允许直接返回多个元素)

vue.js:435 [Vue warn]: Unknown custom element: <my-footer> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

原因:你把局部组件当成全局组件去使用了

解决方案:

正确的注册组件

3、 The "data" option should be a function that returns a per-instance value in component definitions.

原因:在组件中去初始化数据 不允许给data直接赋值一个对象

解决方案: Vue.component('',{

data:function(){
        return {}
       }
    })

4、Uncaught TypeError: Cannot read property 'push' of undefined

原因:push前面的那个变量,其实undefined

解决方案:

this 通过箭头函数来解决问题

5、ERROR in ./src/assets/img/favicon.ico

Module parse failed: C:xampphtdocsframeworkvueprojecttplssrcassetsimgfavicon.ico Unexpected character '' (1:0)

You may need an appropriate loader to handle this file type.

(Source code omitted for this binary file)

解决方案:找到build/webpack.base.conf.js

在41行加上 |ico

6、No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' http://localhost :8080' is therefore not allowed access.

跨域问题


以上所述就是小编给大家介绍的《Vue常见问题及处理》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

需求

需求

[美] 亚德里安•斯莱沃斯基(Adrian J. Slywotzky)、[美]卡尔•韦伯 (Karl Weber) / 魏薇、龙志勇 / 浙江人民出版社 / 2013-6 / 64.9

《财富汇•需求:缔造伟大商业传奇的根本力量》内容简介:需求,是缔造伟大商业传奇的根本力量。《财富汇•需求:缔造伟大商业传奇的根本力量》呈现了人们无法拒绝、竞争对手无法复制的需求创造的六大关键,在人们无奈接受的现状和心中真正期待的理想的这道鸿沟之上,架设起了一道桥梁。 创造需求,需要解开一个谜团,这个谜团是人类学、心理学、科技、设计、经济学、基础设施以及其他众多因素综合而成的奇特组合。《财富汇......一起来看看 《需求》 这本书的介绍吧!

MD5 加密
MD5 加密

MD5 加密工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器