npm.io
0.4.4 • Published 4 years ago

vue-script-insert

Licence
MIT
Version
0.4.4
Deps
2
Size
459 kB
Vulns
0
Weekly
0
Stars
2

vue-script-insert

Module to dynamically load external js into spa

Setup

$ npm install vue-script-insert

Usage

Vue.js
<script>
import {VueScriptInsert} from 'vue-script-insert'

export default {
  components: {
    VueScriptInsert
  },
  ・・・
}
</script>
Nuxt.js
//plugins/vue-script-insert.js

import Vue from 'vue'
import {VueScriptInsert} from 'vue-script-insert/src/installer.js'

Vue.use(VueScriptInsert)
//nuxt.config.js

export default {
    plugins: [
        'plugins/vue-script-insert'
    ],
}

Document

It works by setting prop to the tag. The tag containing the script is passed to url, the id attribute of the html tag is passed to id, and the css style is passed to layout.

<VueScriptInsert :url="adv_url" :id="adv_id" :layout="adv_layout"></VueScriptInsert>
Component props
prop type description
url String Tag strings containing

Keywords