const startDate = new Date(new Date() - 24 * 60 * 60 * 1000 * 30)
const endDate = new Date()
const dataText = ‘’//表格置空
export default {
startDate,
endDate,
dataText,
}


全局使用,示例如下:



import globalVariable from ‘./assets/js/global_variable’
Vue.prototype.GLOBAL = globalVariable


在需要使用的模块文件中使用(无需引入,直接通过`this`使用),示例如下:



data() {
return {
startDate: this.GLOBAL.startDate, //开始时间
endDate: this.GLOBAL.endDate, //结束时间
dataText: this.GLOBAL.dataText, //表格开始置空
};
},


注⚠️:务必以`$`开头,否则会命名冲突!


### 三、全局挂载全局函数


有很多函数在重复使用,所以,我们可以对这些函数进行全局挂载,省时又省力!


实现过程如下:



> 
> 1. 单独新建一个全局变量模块文件,模块中定义一些变量初始状态,用`export default` 暴露出去;
> 2. 在`main.js`中引入,并通过`Vue.prototype`挂载到`vue`实例上面。供其他模块文件使用;
> 3. 或者直接引入到需要的模块文件中使用;
> 
> 
> 


有以下两种方式可实现全局挂载全局函数。


#### 3.1 方式一:Vue.prototype


在`main.js`加入



// Vue 全局挂载自定义函数
// folding为传进来的参数
// internalFolding 为函数名

Vue.prototype.internalFolding = function (folding){
//函数内容
}


在所有组件里可调用函数



this.internalFolding(folding)


这里的引用方式不推荐使用,因为所有的引用都放到`main.js`中会显得很乱!


#### 3.2 方式二:exports.install + Vue.prototype


写好自己需要的公共JS文件(`folding.js`)



exports.install = function (Vue, options) {
Vue.prototype.internalFolding = function (folding){
if(folding){
$(“.abnormal-center-right”).css(“left”,“1%”);
}else{
$(“.abnormal-center-right”).css(“left”,“21%”);
}
};
};


`main.js` 引入并使用



import folding from ‘@/static/js/folding’
Vue.use(folding);


所有组件里可调用函数



this.internalFolding(this.folding);


这里的引用方式推荐使用!


注:`exports.install`为`vue`的插件语法糖,方便用`vue.use` 使用的。


### 四、全局组件挂载


在`main.js`中全局注册到`vue`中。



import MyBread from ‘@/components/common/MyBread.vue’
Vue.component(“MyBread”, MyBread);//全局自定义组件
ES6

  • 列举常用的ES6特性:

  • 箭头函数需要注意哪些地方?

  • let、const、var

  • 拓展:var方式定义的变量有什么样的bug?

  • Set数据结构

  • 拓展:数组去重的方法

  • 箭头函数this的指向。

  • 手写ES6 class继承。

开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】

微信小程序

  • 简单描述一下微信小程序的相关文件类型?

  • 你是怎么封装微信小程序的数据请求?

  • 有哪些参数传值的方法?

  • 你使用过哪些方法,来提高微信小程序的应用速度?

  • 小程序和原生App哪个好?

  • 简述微信小程序原理?

  • 分析微信小程序的优劣势

  • 怎么解决小程序的异步请求问题?

其他知识点面试

  • webpack的原理

  • webpack的loader和plugin的区别?

  • 怎么使用webpack对项目进行优化?

  • 防抖、节流

  • 浏览器的缓存机制

  • 描述一下二叉树, 并说明二叉树的几种遍历方式?

  • 项目类问题

  • 笔试编程题:

最后

技术栈比较搭,基本用过的东西都是一模一样的。快手终面喜欢问智力题,校招也是终面问智力题,大家要准备一下一些经典智力题。如果排列组合、概率论这些基础忘了,建议回去补一下。

Logo

一站式 AI 云服务平台

更多推荐