vue-append

vue-append, like v-html directive, but it can call javascript function
31,452 42
Install
npm install vue-append
Latest Version:2.2.0
Vue:2
License:MIT
Last Updated:Nov 8, 2021
Links: GitHub  ·  npm
Maintainer: hacke2

vue-append

vue-append, like v-html directive, but it can call javascript function

Install

npm install vue-append --save
# or
yarn add vue-append
Es6 module
  • Available through npm as vue-append.
  import VueAppend from 'vue-append'
  Vue.use(VueAppend)
CommonJS
  var VueAppend = require('vue-append')
  Vue.use(VueAppend)
Direct include
  • You can also directly include it with a <script> tag. It will automatically install itself, and will add a global VueAppend.

Event

appended

  • if html append , script downloaded and no throw error, it will fire appended event.

appenderr

  • if throw error when html appended, it will fire appenderr event.

Usage

Using the v-append directive

template:

<div id="app">
    <div v-append="html" @appended="appended"></div>
</div>
<div id="app">
    <div v-append.sync="html" @appended="appended"></div>
</div>

js:

import Vue from 'vue/dist/vue.esm'
import VueAppend from 'vue-append'

// use the plugin
Vue.use(VueAppend);

const html = `
<div id="test">1</div>
<script
  src="https://code.jquery.com/jquery-3.4.1.min.js"
  integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
  crossorigin="anonymous"></script>
<script>
var i = 1;
setInterval(function() {
    document.getElementById("test").innerHTML = ++i;
}, 1000);
</script>

`;

new Vue({
  el: '#app',
  data: {
    html: html
  },
  methods: {
    appended() {
      console.log('appended!');
      // could use jQuery 😊
      alert(window.jQuery);
    }
  }
});

See /example for a timer demo. To build it, run npm install && npm run build.

License

MIT

Related Packages

vue

The progressive JavaScript framework for building modern web UI.

588,019,132 54,801
vue
@vueuse/shared
372,738,348 22,398
@vueuse/core

Collection of essential Vue Composition Utilities

367,188,523 22,398
@vitejs/plugin-vue

The official plugin for Vue SFC support in Vite.

333,357,380 686
eslint-plugin-vue

Official ESLint plugin for Vue.js

266,364,830 4,591

Version History

Version Released License
2.2.0 MIT
2.1.0 MIT
2.0.1 MIT
2.0.0 MIT
1.1.4 MIT