方法一
const s = document.createElement('script');
s.type = 'text/javascript';
s.src = process.env.VUE_APP_TLOGIN;
s.id = 'toploginstruct';
s.setAttribute('data','style=3&placeid=headerBox&laylocate=right&reutrnurl=');
document.body.appendChild(s);
方法二
//引用的页面
<login></login>
import login from './login.vue';
components: {
login
},
//login.vue
<template>
<div>
<login-js></login-js>
</div>
</template>
components: {
'login-js': {
render(createElement) {
return createElement('script', {
attrs: {
id: 'toploginstruct',
data: 'style=3&reutrnurl=https%3a%2f%2flogin.cnki.net%2fTopLoginTest%2fh1.html%26platform%3dkjpt',
type: 'text/javascript',
src: '',
},
});
},
},
},
},