Angular Directive上的Swiper Slider nodeType null错误

时间:2016-01-05 09:39:22

标签: javascript jquery angularjs swiper

以下是我的指示模板

<div class="swiper-container">

        <div class="swiper-wrapper">    
            <div class="swiper-slide">
                <img ng-src="{{vm.imageUrl | imageFilter:vm.cdnPath}}" onerror="" alt=""/>
            </div>
            <div class="swiper-slide" ng-repeat="image in vm.imageList track by $index">
                <img ng-src="{{image | imageFilter:vm.cdnPath}}" onerror="" alt=""/>
            </div>
        </div>

        <div class="swiper-pagination"></div>
        <div class="swiper-button-prev"></div>
        <div class="swiper-button-next"></div>
        <div class="swiper-scrollbar"></div>
</div>

以下是我的指示

export default class ProductGallery {
    constructor() {
        this.templateUrl = 'components/product-detail/ProductGallery/product-gallery.directive.html';
        /*require*/
        this.restrict = 'E';

        this.scope = {
            imageUrl: '=',
            imageList: '=',
            zoomImageList: '=',
            cdnPath: '@'
        };

        this.controller = DirectiveController;
        this.controllerAs = 'vm';
        this.bindToController = true;
    }

    link(scope) {
        scope.$watchGroup(['vm.imageUrl', 'vm.imageList'], function(newValues, oldValues, scope) {
            if(newValues[0] && newValues[1]){

                var mySwiper = new Swiper ('.swiper-container', {
                    direction: 'vertical',
                    loop: true
                });
            }
        });
    }
}

class DirectiveController {
    constructor($scope) {

    }
}

DirectiveController.$inject = ['$scope'];

我收到错误 TypeError:无法在Object.Swiper读取null的属性'nodeType'(eval at ,无法找到它的解决方案。

0 个答案:

没有答案
相关问题