0

我正在尝试在我的 vue chrome 扩展中使用 ar.js 和 aframe。在 vue ui 中构建扩展后,我的内容安全策略有问题:

Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self'".

为了解决这个问题,我更改了 dist 文件夹清单中的 csp,但我需要解决这个问题。谁能帮我?

这是我的代码:

<template>
  <a-scene ref="scene" vr-mode-ui="enabled: false" embedded arjs='sourceType: webcam; sourceWidth:1280; sourceHeight:960; displayWidth: 1280; displayHeight: 960; debugUIEnabled: false;'>
    <a-camera gps-camera rotation-reader></a-camera>
    </a-scene>
</template>

<script>
import 'aframe/dist/aframe-master'
import 'ar.js'

export default {
  name: 'HelloWorld',
  data() {
    return {
      coords: []
    }
  },
  mounted() {
    //browser.runtime.sendMessage({})
    this.initPosition()
    .then( () => {
      this.addEntity()
    })
  },
  computed: {

  },
  methods: {
    async initPosition() {
      navigator.geolocation.getCurrentPosition( (position) => {
        console.log(position)
        this.coords.push([ position.coords.latitude, this.coords.position.longitude ])
      })
    },
    async addEntity() {
      const model = document.createElement('a-entity')
        model.setAttribute('gps-entity-place', `latitude: ${this.coords[0]}; longitude: ${this.coords[1]};`);
        model.setAttribute('gltf-model', './assets/zombie/zombie.gltf');
        model.setAttribute('rotation', '0 180 0');
        model.setAttribute('animation-mixer', '');
        model.setAttribute('scale', '0.5 0.5 0.5');
        this.$refs.scene.appendChild(model)
    } // end addEntity
  }
}
</script>
4

0 回答 0