problem
Thinking
Solution
export default { mounted() { const s = document.createElement('script'); s.type = 'text/javascript'; s.src = 'https://g.alicdn.com/dingding/dinglogin/0.0.2/ddLogin.js'; document.body.appendChild(s); }, }
Use createElement
method:
Export default { Components: { 'dingtalk' : { the render (the createElement) { return the createElement ( 'Script' , { attrs: { type: 'text / JavaScript' , the src: 'https://g.alicdn.com/dingding/ dinglogin / 0.0.2 / ddLogin.js' , }, }, ); }, }, }, } // use <dingtalk> </ dingtalk> call page
The ultimate program
export default { components: { 'remote-js': { render(createElement) { return createElement('script', { attrs: { type: 'text/javascript', src: this.src }}); }, props: { src: { type: String, required: true }, }, }, }, }
Instructions:
<remote-js src="https://g.alicdn.com/dingding/dinglogin/0.0.2/ddLogin.js"></remote-js>