vue-ba的bug修复

vue-ba使用v-track-pageview时,值设为字符串会报错
Error in directive track-pageview bind hook: "TypeError: Cannot assign to read only property '0' of string '/index/search'"

研究了下源码,有两种解决方式:
1.对象字面量传递参数
v-track-pageview="{pageURL: '/test'}"

2.修改源码

if (typeof binding.value === 'object') {
      let value = binding.value
      if (value.pageURL) args.push(value.pageURL)
      console.log(args, 'aaaaa')
    } else if (typeof binding.value === 'string' && binding.value) {
      args = binding.value.split(',')
      // args.forEach((arg, i) => (arg[i] = arg.trim()))  此行代码错误
      args.forEach((arg, i) => (args[i] = arg.trim()))  // 修正代码
    }

你可能感兴趣的:(vue-ba的bug修复)