Global.vue
要共用的全域参数
<script>
const _token = "";
const userid = "";
export default {
_token, //使用者地址
userid,
};
</script>
使用方式2:
直接在需要使用的档案 引入全域性变数模组
看范例
<template>
<div>{{ token }}</div>
</template>
<script>
import global_ from '../config/Global'//引用模组进来
export default {
data () {
return {
token:global_.token,
}
}
}
</script>
使用方式2:
在入口档案 main.js,
将Global.vue 挂载至 Vue.prototype
import global_ from './config/Global'
Vue.prototype.GLOBAL = global_//挂载到Vue例项上面
//直接通过this访问全域性变数。
<template>
<div>{{ token }}</div>
</template>
<script>
export default {
data () {
return {
token:this.GLOBAL.token,
}
}
}
</script>
<<: Day27 参加职训(机器学习与资料分析工程师培训班),专题讨论
>>: Ruby基本介绍(二) && Palindrome-number解法
Function 在程序设计中的 Function(有时候翻译函式)类似数学中的 Function(...
昨天我们安装了 Next 这个布景主题,今天就要来介绍如何编辑设定 Next,以及 Next 提供了...
当我们要将父元素的资料传递到子元件的时候会使用 props,但假设有很多个 component,曾曾...
一、前言 想要进行资料分析,要做的第一件事当然是收集资料,所幸现在是2021,我们不需要为了股票资料...
「鲑鱼均,因为一场鲑鱼之乱被主管称为鲑鱼世代,广义来说以年龄和脸蛋分类的话这应该算是一种 KNN 的...