찾다

 >  Q&A  >  본문

javascript - zepto 错误

index.html

1

2

3

4

5

6

7

8

9

<code><script src="//cdn.staticfile.org/zepto/1.1.4/zepto.min.js"></script>

<script src="./assets/js/script.js"></script>

<script>

    $(function(){

        hsh.home();

        hsh.init();

    });

</script>

</code>

script.js

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

<code>var hsh = (function($){

 

    return {

 

        init: function(){

 

            //ajax 默认设置

            $.ajaxSetting({

 

                type: "post",

                url: apiUrl,

                dataType : "json",

                async: true,

                error: function(xhr, errorType, error){

 

                },

                beforeSend: function(xhr, setting){

 

                },

                success: function(data, status, xhr){

 

                },

                complete: function(xhr, status){

 

                }

            });

 

            alert("init");

            //init.End

        },

 

        home: function(){

 

            alert("home");

        }

    }

 

})(Zepto);

</code>

FireBug 报错

TypeError: $.ajaxSetting is not a function

alert("init"); 也没执行!

不知道 这种方式的 zepto 应该怎么写! 求大神指教! -_-|||

PHP中文网PHP中文网2904일 전317

모든 응답(1)나는 대답할 것이다

  • PHPz

    PHPz2017-04-10 14:48:38

    看Doc: http://zeptojs.com/#$.ajaxSettings

    ajaxSettings而不是ajaxSetting

    회신하다
    0
  • 취소회신하다