Home > Web Front-end > H5 Tutorial > Share an example code of vue global configuration

Share an example code of vue global configuration

零下一度
Release: 2017-05-11 14:25:27
Original
2197 people have browsed it

Today we learn about vue global configuration. I hope it will help us understand the global configuration of vue and develop quickly.

Vue.config is the global configuration object of vue. Contains all global properties of Vue:

The code is as follows:

  1. silent:boolean(默认值:false)----取消Vue的所有的日志与警告 ;用法:Vue.config.silent = true
    optionMergeStrategies:{[key:string]:Function}(默认是空对象{})
    vue.config.optionMergeStrategies._my_option = function (parent, child, vm) {
    return child + 1
    }
     自定义合并策略的选项:接受第一个参数是父实例,第二个参数实例为子实例,第三个参数是Vue实例上下文
    const Profile = Vue.extend({
    _my_option: 1
    })
     devtools:boolean(默认是true,生成版为false) 用法:Vue.config.devtools = true 配置是否允许vue-devtools检查代码。开发版本默认为:true ,生产为false
    errorHandler:Funtion (默认值是默认抛出错误)用法:
    Vue.config.errorHandler = function (err, vm) {
    // handle error
    }在指定组件的渲染和观察期间未捕获错误的处理函数。这个处理函数被调用时,可以获取错误信息和vue实例
    ignoredELements:array<string>(默认是【】)用法:
    Vue.config.ignoredElements = [
    &#39;my-custom-web-component&#39;, &#39;another-web-component&#39;
    ]拼错组件名称,从而抛出一个关于Unknown custom element 
    keyCodes:{[ key:string]:number | Array <number>} (默认是{})用法:Vue.config.keyCodes = { v:86, F1:112,mediaPlayPause:179,up:[38,87]} 这个多半伴随v-on 自定义键位别名。
    Copy after login

[Related recommendations]

1. Free h5 online video tutorial

2. HTML5 full version manual

3. php.cn original html5 video tutorial

The above is the detailed content of Share an example code of vue global configuration. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template