Javascript 流星计划中的Skel导入
我是Meteor的新手,我正在尝试将一个javascript文件:skel.min.js、skel-layout.min.js和skel-viewport.min.js导入到项目中 这3个文件位于client/js路径上(Javascript 流星计划中的Skel导入,javascript,meteor,skel,Javascript,Meteor,Skel,我是Meteor的新手,我正在尝试将一个javascript文件:skel.min.js、skel-layout.min.js和skel-viewport.min.js导入到项目中 这3个文件位于client/js路径上(client/js/skel.min.js,client/js/skel layout.min.js和client/js/skel viewport.min.js) 我在“client/baseLayout/baseLayout.js”中有基本布局,我提供如下内容: impor
client/js/skel.min.js
,client/js/skel layout.min.js
和client/js/skel viewport.min.js
)
我在“client/baseLayout/baseLayout.js”中有基本布局,我提供如下内容:
import angular from 'angular';
import angularMeteor from 'angular-meteor';
import uiRouter from 'angular-ui-router';
import * as skel from '../js/skel.min.js';
(function ($) {
skel.breakpoints ({
xlarge: '(max-width: 1680px)',
large: '(max-width: 1280px)',
medium: '(max-width: 980px)',
small: '(max-width: 736px)',
xsmall: '(max-width: 480px)',
'xlarge-to-max': '(min-width: 1681px)',
'small-to-xlarge': '(min-width: 481px) and (max-width: 1680px)'
});
.
.
.
但它总是向我显示以下错误:
Uncaught ReferenceError: skel is not defined
at skel-layout.min.js (app.js? hash = e2c356f13dbdbc8f5ea02b405b7c429aff6b8bef: 699)
at fileEvaluate (modules-runtime.js? hash = 8587d188e038b75ecd27ed2469a52b269e38fb62: 343)
at require (modules-runtime.js? hash = 8587d188e038b75ecd27ed2469a52b269e38fb62: 238)
at app.js? hash = e2c356f13dbdbc8f5ea02b405b7c429aff6b8bef: 1157
我试图移动文件,但也不起作用
我做错了什么
我的包裹:
# Meteor packages used by this project, one per line.
# Check this file (and the other files in this directory) into your repository.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.
meteor-base@1.1.0 # Packages every Meteor app needs to have
mobile-experience@1.0.5 # Packages for a great mobile UX
mongo@1.2.2 # The database Meteor supports right now
blaze-html-templates@1.0.4 # Compile .html files into Meteor Blaze views
reactive-var@1.0.11 # Reactive variable for tracker
tracker@1.1.3 # Meteor's client-side reactive programming library
standard-minifier-css@1.3.5 # CSS minifier run for production mode
standard-minifier-js@2.1.2 # JS minifier run for production mode
es5-shim@4.6.15 # ECMAScript 5 compatibility for older browsers
ecmascript@0.8.3 # Enable ECMAScript2015+ syntax in app code
shell-server@0.2.4 # Server-side component of the `meteor shell` command
insecure@1.0.7 # Allow all DB writes from clients (for prototyping)
iron:router
twbs:bootstrap
rlespagnol:skeleton-css
johnantoni:meteor-skeleton
jquery
fourseven:scss
感谢看起来问题不在于你发布的代码,但当Meteor急切地加载文件时,它会做两件事
skel layout
在skel.min
之前运行,这是控制台中的错误skel.min
需要先运行skel.min
使用UMD模式,Meteor使用common.js,因此它向模块加载器注册自身,以便可以使用require()
调用它,而不是将自身加载到全局窗口
查看skel
repo中的代码,skel布局
和skel视口
不使用UMD或尝试require()
或import
skel,它只希望它在当前范围内可用
换句话说。Skel已经把他们的模块模式搞砸了一半
谢天谢地,有一个快速解决办法。
将所有三个文件放在客户机/兼容性
文件夹中,并在名称前面加上加载顺序:
1-skel.min.js
2-skel-layout.min.js
3-skel-viewport.min.js
对于compatibility
文件夹中的文件,Meteor不会在新的闭包中加载它们,因此它们可以自由地污染全局范围