[英]Sharepoint Online SPFX Web parts React - How to dynamically choose script based on enviro?
I want to dynamically choose which script to use in my web part. 我想动态选择要在Web部件中使用的脚本。
My imports are as follows: 我的进口如下:
import * as jQuery from 'jquery';
import 'jqueryui';
And I want to do this in my component: 我想在我的组件中执行此操作:
//Select script to us
//if (Environment.type === EnvironmentType.Local) {
//import * as jQuery from 'jquery';
//import 'jqueryui';
//} else if (){
SPComponentLoader.loadCs('//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css');
SPComponentLoader.loadScript('//code.jquery.com/jquery-min.1.12.1.js');
} ;
Is this possible? 这可能吗?
I think you can make use of require
method somewhat as below: 我认为您可以使用require
方法,如下所示:
//Select script to use
if (Environment.type === EnvironmentType.Local) {
require('jQuery');
require('jqueryui');
} else if (){
SPComponentLoader.loadCss('//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css');
SPComponentLoader.loadScript('//code.jquery.com/jquery-min.1.12.1.js');
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.