發現左一個可以玩殘你嘅咪記大bug

综合技术 2018-06-18

發現左一個可以玩殘你嘅咪記大bug,如果你寫sharepoint兼用typescript但係又想用jquery, 你好可能會用:

import * as $ from ‘jquery’;

如果嗰畫面得一個webpart,甘你會無事,如果有多個webpart(見下圖),你reload幾次就會撞到有一次某幾個webpart無哂野,因為jquery撞左,網上有啲友話係config.json個externals加返jquery呢一招我試過唔得。但我撞到有一招係work嘅:

SPComponentLoader.loadScript('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', { globalExportsName: 'jQuery' }).then((jQuery: any): void => {
			var $ = jQuery;
			SPComponentLoader.loadScript('https://owlcarousel2.github.io/OwlCarousel2/assets/owlcarousel/owl.carousel.js', {}).then((): void => { }).then((): void => {

				$(".owl-carousel").owlCarousel();
			});
		});

Post Views: 14

责编内容by:Kernel, Virus and Cloud (源链)。感谢您的支持!

您可能感兴趣的

jQuery实现点击开关图片切换 原型大概是这样的 image 需求:点击右侧的蓝色眼睛,会变成 关键代码: /* 实现图片切换 */ $(".imgcl...
Internet Explorer does not recognize jquery in scr... This works in FF and in Chrome but the click has no action in IE. This is the ...
moving menu from horizontal to vertical as user sc... I'm currently running Wordpress with Twitter Bootstrap, bhtml5 boiler plate, ...
JQuery Modal Dialog, ie6 non-secure secu... (Please don't bother asking why we support ie6.) We're creating custom Alert/C...
The code does not work synchronously in IE with Jq... I'm having major difficulties getting IE to run jscript code synchronously. Othe...