使用方法 - 单个资源引入
// 当页面渲染完毕后马上调用下面的函数,这个函数是在当前页面 - 设置 - 生命周期 - 页面加载完成时中被关联的。
export function didMount() {
console.log(`「页面 JS」:当前页面地址 ${location.href}`);
// console.log(`「页面 JS」:当前页面 id 参数为 ${this.state.urlParams.id}`);
// 更多 this 相关 API 请参考:https://www.yuque.com/yida/support/ocmxyv#OCEXd
// document.title = window.loginUser.userName + ' | 宜搭';
this.utils.loadScript('https://g.alicdn.com/code/lib/jquery/3.5.1/jquery.min.js').then(res => {
console.log('success');
}).catch(error => {
this.utils.toast({
title: '资源引入错误!',
type: 'error'
});
});
}
使用方法 - 多个资源引入
export async function didMount() {
console.log(`「页面 JS」:当前页面地址 ${location.href}`);
// console.log(`「页面 JS」:当前页面 id 参数为 ${this.state.urlParams.id}`);
// 更多 this 相关 API 请参考:https://www.yuque.com/yida/support/ocmxyv#OCEXd
// document.title = window.loginUser.userName + ' | 宜搭';
try {
await this.utils.loadScript('https://g.alicdn.com/code/lib/jquery/3.5.1/jquery.min.js');
await this.utils.loadScript('https://taitems.github.io/jQuery.Gantt/js/jquery.fn.gantt.js');
await this.utils.loadStyleSheet('https://www.jqueryscript.net/demo/Simple-Chart-Plugin-with-jQuery-Gantt-Chart/css/style.css');
} catch (e) {
this.utils.toast({
title: '资源引入错误!',
type: 'error'
});
};
}
引入三方 CSS 资源
this.utils.loadStyleSheet(src);
发表评论 取消回复