2

我有一个使用 turn.js 的 Ionic v1 项目,但现在我使用的是 Ionic v2。我在使用 jQuery 导入 turn.js 时遇到问题。

angular.module('albumController', [])

.directive('flipbook', function () {
return {
    restrict: 'E',
    replace: true,
    compile: function (element, attrs) {
        element.turn({
            width: '300px',
            height: '300px',
            pages: 8
        }).turn('peel', 'br');

        element.addClass('flipbook');
        return function (scope, el) {
            el.on('click', '[data-page]', function (e) {
                el.turn('page', $(e.target).data('page'));
            }); 
        };
    },
    templateUrl: "flipbook.html"
}
});

谢谢!

4

1 回答 1

0

不知道你是否已经有了答案。对我来说,我执行以下操作:

  1. 为 ionic 安装 jquery(在此处查看
  2. npm install --save turn.js

  3. import $ from "jquery"; import "turn.js";

只是你可以使用 $().turn();

希望它有所帮助:D

于 2017-05-11T11:41:52.977 回答