Open yaolunmao opened 4 years ago
好吧 我知道原因了 是因为我引用jQuery和js之后在您的script.ejs里面又引了一遍jQuery 把我的覆盖了 这样的话我如果不改script.ejs就不可以在layout里面引用js了 这个下版可以修改一下吗 把您的jQuery的引用放到上面去
你好请问你是怎么让外部js生效的? 我试图在script.ejs里加入 canvas-next.min.js 然后报了一大段错
plugin.js:60 Uncaught DOMException: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The HTMLImageElement provided is in the 'broken' state.
at new b (http://*域名*/js/plugin.js:60:205)
at new b (http://*域名*/js/plugin.js:51:76)
at HTMLImageElement.<anonymous> (http://*域名*/js/diaspora.js:245:27)
at HTMLImageElement.dispatch (http://*域名*/js/jquery.min.js:3:4663)
at HTMLImageElement.i (http://*域名*/js/jquery.min.js:3:628)
at Object.trigger (http://*域名*/js/jquery.min.js:3:3348)
at HTMLImageElement.<anonymous> (http://*域名*/js/jquery.min.js:3:10834)
at Function.each (http://*域名*/js/jquery.min.js:2:11819)
at init.each (http://*域名*/js/jquery.min.js:2:8381)
at init.trigger (http://*域名*/js/jquery.min.js:3:10810)
我在diaspora\source\js文件夹下面新增了一个js文件,在我本地测试这个js文件是没有问题的,然后我又改了diaspora\layout.ejs文件引入那个js, `
然后报错了 错误信息是Uncaught TypeError: $.fn.snow is not a function 这是我的js方法
(function ($) { $.fn.snow = function (options) { var $flake = $('<div id="snowbox" />').css({ 'position': 'absolute', 'z-index': '9999', 'top': '-50px' }).html('❄'), documentHeight = $(document).height(), documentWidth = $(document).width(), defaults = { minSize: 10, maxSize: 20, newOn: 1000, flakeColor: "#AFDAEF" /* 此处可以定义雪花颜色,若要白色可以改为#FFFFFF */ }, options = $.extend({}, defaults, options); var interval = setInterval(function () { var startPositionLeft = Math.random() * documentWidth - 100, startOpacity = 0.5 + Math.random(), sizeFlake = options.minSize + Math.random() * options.maxSize, endPositionTop = documentHeight - 200, endPositionLeft = startPositionLeft - 500 + Math.random() * 500, durationFall = documentHeight * 10 + Math.random() * 5000; $flake.clone().appendTo('body').css({ left: startPositionLeft, opacity: startOpacity, 'font-size': sizeFlake, color: options.flakeColor }).animate({ top: endPositionTop, left: endPositionLeft, opacity: 0.2 }, durationFall, 'linear', function () { $(this).remove() }); }, options.newOn); }; })(jQuery); $(function () { $.fn.snow({ minSize: 5, /* 定义雪花最小尺寸 */ maxSize: 50,/* 定义雪花最大尺寸 */ newOn: 300 /* 定义密集程度,数字越小越密集 */ }); });
这是什么原因啊