【问题标题】:How to use jquery with brunch如何在早午餐中使用 jquery
【发布时间】:2016-01-16 02:51:55
【问题描述】:

我正在尝试设置主干应用程序,但出现“$ 未定义”错误。

Tree : 
      app :/
           app.js
           js :/
               jquery.js
               underscore.js
               backbone.js

我有一个早午餐的 config.coffee 文件:

exports.config =   paths:
    public: 'www'   files:
    javascripts:
      joinTo:
        'js/atf.js': /^app/
      order:
        before: [
          'app/js/jquery-2.0.2.min.js',
          'app/js/underscore.js',
          'app/js/backbone.js'
        ]

    stylesheets:
      joinTo:
        'css/atf.css': /^app/

    templates:
      joinTo: 'js/atf.js'

我的 index.html 文件:

<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="fr"> <![endif]-->
<!--[if IE 7]>    <html class="no-js lt-ie9 lt-ie8" lang="fr"> <![endif]-->
<!--[if IE 8]>    <html class="no-js lt-ie9" lang="fr"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="fr" x-manifest="/manifest.appcache"> <!--<![endif]-->
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <title>Test</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <link rel="stylesheet" type="text/css" media="all" href="/css/atf.css?v=2">
  <script src="/socket.io/socket.io.js"></script>
  <script src="/js/atf.js?v=3"></script>
  <script>require('app');</script>
</head>
<body></body>
</html>

我的 app.js 文件只是为了进行测试:

$(function(){
    alert('test');
});

有人可以帮助我吗?谢谢!

【问题讨论】:

    标签: javascript jquery backbone.js underscore.js brunch


    【解决方案1】:

    将文件从app/js 移动到vendor(创建此目录)。并将javascripts.joinTo 更改为您在templates 中使用的那个。

    这应该可以解决问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-08-27
      • 2015-01-17
      • 2016-01-19
      • 1970-01-01
      • 2015-03-12
      • 2012-10-18
      • 2019-01-04
      相关资源
      最近更新 更多