我正在使用backbone + requirejs + jquery,我在当前的html页面(精确的主干html模板)中加载了jquery插件有问题.
有我的要求配置:
require.config({
paths: {
// ... some code about backbone config
jquery: '/js/lib/jquery/jquery.min',
'jquery.camera' : '/js/jquery/jquery.camera'
},
shim: {
// ... some code about backbone config
'jquery.camera': ['jquery']
}
});
Run Code Online (Sandbox Code Playgroud)
在我的布局html页面中,我有:
<script type='text/javascript' src='/js/jquery/jquery.camera.js'></script>
Run Code Online (Sandbox Code Playgroud)
在我的模板页面中,我有:
<script type="text/javascript">
jQuery(function() {
jQuery('#test').camera({
...
</script>
Run Code Online (Sandbox Code Playgroud)
最后我的浏览器消息:
Uncaught TypeError: Object [object Object] has no method 'camera'
Run Code Online (Sandbox Code Playgroud)
你有什么主意吗?
同时我还有另一个问题,在我们当前页面中包含一些js代码的最佳方法是使用backbone,requirejs等.
谢谢 :)