如何在framework7中使用jquery插件

时间:2016-08-20 07:52:36

标签: jquery html-framework-7

插件是http://www.jsplugins.net/jquery-seat-charts-plugin/ 代码如下,我在f7中使用它,但它说"未捕获的TypeError:$$(...)。seatCharts不是函数" 我已经将$更改为$$。 $(document).ready(function(){

var sc = $('#seat-map').seatCharts({
    map: [
        'aaaaaaaaaaaa',
        'aaaaaaaaaaaa',
        'bbbbbbbbbb__',
        'bbbbbbbbbb__',
        'bbbbbbbbbbbb',
        'cccccccccccc'
    ],
    seats: {
        a: {
            price   : 99.99,
            classes : 'front-seat' //your custom CSS class
        }

    },
    click: function () {
        if (this.status() == 'available') {
            //do some stuff, i.e. add to the cart
            return 'selected';
        } else if (this.status() == 'selected') {
            //seat has been vacated
            return 'available';
        } else if (this.status() == 'unavailable') {
            //seat has been already booked
            return 'unavailable';
        } else {
            return this.style();
        }
    }
});

//Make all available 'c' seats unavailable
sc.find('c.available').status('unavailable');

/*
Get seats with ids 2_6, 1_7 (more on ids later on),
put them in a jQuery set and change some css
*/
sc.get(['2_6', '1_7']).node().css({
    color: '#ffcfcf'
});

console.log('Seat 1_2 costs ' + sc.get('1_2').data().price + ' and is currently ' + sc.status('1_2'));

});

3 个答案:

答案 0 :(得分:2)

下载jQuery并将其添加到您的项目中。你需要在framework7.js之前写它,因为它使用它。所以要小心 你会在这里找到更多。 https://stackoverflow.com/a/35590532/6594294

答案 1 :(得分:1)

在正文末尾添加所有JavaScript文件,并在JS Script标记的末尾添加jquery。

enter image description here

答案 2 :(得分:0)

您必须先初始化$$。

var $$ = Dom7;