有没有可能将js装入localStorage加速程序执行

JavaScript07

有没有可能将js装入localStorage加速程序执行,第1张

首先localStorage只有在html5中才有,所以要确保浏览器支持html5,建议用谷歌浏览器。

其次创建一个js文件如 tempcache.js

//临时存储

var TempCache = {

cache: function (value) {

localStorage.setItem("EasyWayTempCache", value)

},

getCache: function () {

return localStorage.getItem("EasyWayTempCache")

},

setItem: function (key, value) {

localStorage.setItem(key, value)

},

getItem: function (key) {

return localStorage.getItem(key)

},

removeItem: function (key) {

return localStorage.removeItem(key)

}

}

调用时先引用该js文件 然后看下面的示例

设置值

TempCache.setItem("name","张三")

取值

var name=TempCache.getItem("name");

移除设置的值

TempCache.removeItem("name")

1、字体安装的位置还是很好找的,首先我们打开我的电脑并点击系统盘,相信绝大多数用户都是C盘,如果你的具体情况不一样,那就点击具体的系统盘

2、找到一个名为“windows”的文件夹并打开

3、随后找到一个名为“fonts”文件夹并打开

4、打开后就能够看到这台电脑里所存在的所有字体。

以上就是字体安装在哪个文件夹的具体位置,用户根据提示去寻找即可。

1.首先创建一个js

ex: test.js 

const referrerPhone = [

  { pattern: /^1[3456789]\d{9}$/, message: '手机号格式不正确', trigger: 'blur' }

]

export default {

referrerPhone 

}

import validators  from '../路径/test.js'

定义成对象方便调用

Vue.prototype.$validators  = validators 

this.$validators.referrerPhone 

=======================================================================================================

第二种 不是公用

1.创建一个 js

// 弹框提示

function tips(this_, message_, type_){

  this_.$message({

    message: message_,

    type: type_

  })

export { //很关键

  tips,

}

import { tips} from '../xx.js'

tips(this, '非法操作,不能删除admin用户!', 'error')