vue-script-insert

Module to dynamically load external js into spa
3,187 2
Install
npm install vue-script-insert
Latest Version:0.4.4
Vue:3
License:MIT
Last Updated:Apr 22, 2022
Links: GitHub  ·  npm
Maintainer: tf0101

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

<VueScriptInsert :url="adv_url" :id="adv_id" :layout="adv_layout"></VueScriptInsert>

Component props

prop type description
url String Tag strings containing <script>.
id String ID (unique identifier) for an element in the id attribute of an HTML tag.
layout Object CSS styles, passed as an associative array

Usage examples

//Vue

<template>
    <VueScriptInsert :url="adv_url" :id="adv_id" :layout="adv_layout"></VueScriptInsert>
</template>

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

export default {
    components: {
        VueScriptInsert
    },
    data() {
        return {
            adv_url:'tag',
            adv_id:'id',
            adv_layout:{
                width: "1080px",
                height :"110px",
                },
            }
        }
    }
</script>
//Nuxt

<template>
    <VueScriptInsert :url="adv_url" :id="adv_id" :layout="adv_layout"></VueScriptInsert>
</template>

<script>
export default {
  data() {
    return {
      adv_url:'tag',
      adv_id:'id',
      adv_layout:{
          width: "1080px",
          height :"110px",
        },
    }
  }
}
</script>

Detailed layout

Detailed layout can be specified by using ids in <style> tags. ※ At this point, you need to specify the layout of the iframe.

<style>
    #id iframe{
        ・・・
    }
</style>

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/tf0101/vue-script-insert.

License

MIT License

Related Packages

@vesperjs/nuxt

This is Vesper for Nuxt.

8,411 1
@vesperjs/shared

This is Shared library for Vesper.

7,421 1
@nuxtjs/dayjs

The best way for use Day.js easily in your Nuxt.js project.

404,248
vue-preloader

Vue-Preloader is a versatile and easy-to-use Vue.js component that allows you to...

39,992 37
@neneos/nuxt-animate.css

An animate.css module for nuxt

14,917 10

Version History

Version Released Vue License
0.4.4 ^3.0.0 MIT
0.4.3 ^3.0.0 MIT
0.4.2 ^3.0.0 MIT
0.4.0 ^3.0.0 MIT
0.3.9 ^3.0.0 MIT