在Vuecli的组件中使用script标签引入外部文件

在正常网页中引入script标签

<script src="https://editor.csdn.net></script>

思路:创建一个创建元素script标签的方法,在使用外部文件前调用

在Vue-cli某个组件中引入这种网址的标签

<template>
</template>

<script>
export default {
  mounted: function() {
    this.createdLoca()
  },
  methods: {
    createdLoca() {
      var script = document.createElement('script')
      script.type = 'text/javascript'
      script.async = true
      script.src = 'http://需要引入的地址'
      document.head.appendChild(script)
    }
  }
}
</script>

你可能感兴趣的:(在Vuecli的组件中使用script标签引入外部文件)