This is done because a JS file needs to be introduced inside a component to locate it. If put in index.html, so each component will have this JS. So it needs to be introduced separately within the component.
The first operation of the DOM introduces JS:
default { mounted () { const s = document.createelement ('script'); 'text/javascript'; ' Https://g.alicdn.com/dingding/dinglogin/0.0.2/ddLogin.js ' ; Document.body.appendChild (s); },}
The second method of use createElement
:
Exportdefault{components: {'Dingtalk': {render (createelement) {returncreateelement ('Script', {attrs: {type:'Text/javascript', SRC:'Https://g.alicdn.com/dingding/dinglogin/0.0.2/ddLogin.js', }, }, ); }, }, },}//use <dingtalk></dingtalk> to invoke in a page
The third encapsulates a component:
export default {components: { " remote-js return createelement ( ' script " , {attrs: {type: " text/ JavaScript ", src: this .src}}); }, Props: {src: {type:string, Required: true
using:<remote-js src= "Your need for the JS file address" ></remote-js>
A remote JS file is introduced inside the Vue component