Vue【从无到有从有到无】【F3】【问题】使用eval,vue eslint会报 eval can be harmful

问题

使用eval,vue eslint会报 eval can be harmful

 

解决

// 解决 使用eval,vue eslint会报 eval can be harmful
evil (fn) {
  // 一个变量指向Function,防止有些前端编译工具报错
  let Fn = Function
  return new Fn('return ' + fn)()
},
// eval('this.echartsData.keywords = (' + keywordsTemp + ')')
// 等价
this.echartsData.keywords = this.evil(keywordsTemp)

你可能感兴趣的:(Vue)