Vue How to introduce a remote JS file

Source: Internet
Author: User

operate directly on the DOM:

default {mounted () {  = document.createelement (' script ');   = ' Text/javascript ';   = ' Https://g.alicdn.com/dingding/dinglogin/0.0.2/ddLogin.js ';  Document.body.appendChild (s); },}

Ideas:

The method of using Vue createElement  :

default {Components  :{' Dingtalk ': {   render (createelement) {    return  createelement (     ' script ',     {      attrs: {       ' text/javascript ',       ' https ://g.alicdn.com/dingding/dinglogin/0.0.2/ddlogin.js ',      },     },    );   },  //  use <dingtalk></dingtalk> to invoke in a page

The ultimate Solution:

By encapsulating a component remote-js  implementation:

default   {components:{' Remote-js ': {  render (createelement)}   {return this . src}});  },  props: {   true  },},},}  ,}

How to use:

<src= "Https://g.alicdn.com/dingding/dinglogin/0.0.2/ddLogin.js"  ></remote-js>

Reference:

Http://www.jb51.net/article/111634.htm

Original link: http://blog.csdn.net/sinat_17775997/article/details/55798611

Vue How to introduce a remote JS file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.