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