v-remote-js

2.0.0 • Public • Published

v-remote-js

Build Status

在vue 单页应用中,引入远程js 和css 来避免全局引入的问题, 不支持IE

Install

npm install v-remote-js  -S

Quick Start

在 main.js 注册插件 使其成为一个全局组件
import Vue from 'vue'
import vRometeJs from 'v-remote-js'
Vue.use(vRometeJs)
 <!-- 之后在每个xx.vue 文件中 写法如下 -->
<remote-css :hrefs="hrefs"></remote-css>
<remote-js :srcArr="srcArr" @scriptLoad="callbackFn"></remote-js>
// 支持加载多个远程资源,加载多个js 注意依赖顺序
export default {
    data(){
        return {
           hrefs:['http://xxx.css'],
           srcArr:['http://xxxx1.js','http://xxxx2.js']
        }
   }
   methods:{
       // 远程js 加载完执行的回调
       callbackFn(){
       // ...写你的逻辑
       }  
   }
}

Package Sidebar

Install

npm i v-remote-js

Weekly Downloads

12

Version

2.0.0

License

MIT

Unpacked Size

5.49 kB

Total Files

6

Last publish

Collaborators

  • xintairuan