简体   繁体   English

离子载玻片如何在离子1.2.4上起作用(或者它对1.2.4有效吗?)

[英]How does ion-slides work on ionic 1.2.4 (Or does it work for 1.2.4?)

I used the doc http://ionicframework.com/docs/nightly/api/directive/ionSlides/ and basically use the starter app template. 我使用了文档http://ionicframework.com/docs/nightly/api/directive/ionSlides/ ,基本上使用了入门应用程序模板。 I added the html to the template and the js part to my controller, but it gave out error ReferenceError: fade is not defined and shows nothing.. 我将html添加到模板中,并将js部分添加到我的控制器中,但是它给出了错误ReferenceError:fade未定义且没有显示任何内容..

Does anyone has a working ion-slides example for 1.2.4 ionic? 有没有人有1.2.4离子的工作离子幻灯片示例? My assumption is that they changed something but haven't produced the doc for it yet. 我的假设是他们改变了一些东西,但还没有为它制作文档。

Here is the code that I used, I added the js part to controller and the html to my view. 这是我使用的代码,我将js部分添加到控制器,将html添加到我的视图中。

$scope.options = {
  loop: false,
  effect: fade,
  speed: 500,
}
$scope.data = {};
$scope.$watch('data.slider', function(nv, ov) {
  $scope.slider = $scope.data.slider;
})
<ion-slides  options="options" slider="data.slider">
  <ion-slide-page>
    <div class="box blue"><h1>BLUE</h1></div>
  </ion-slide-page>
  <ion-slide-page>
    <div class="box yellow"><h1>YELLOW</h1></div>
  </ion-slide-page>
  <ion-slide-page>
    <div class="box pink"><h1>PINK</h1></div>
  </ion-slide-page>
</ion-slides>

When going into the view I received this error: 进入视图时,我收到此错误:

ReferenceError: fade is not defined
at new (controllers.js:22)
at invoke (ionic.bundle.js:17762)
at Object.instantiate (ionic.bundle.js:17770)
at ionic.bundle.js:22326
at self.appendViewElement (ionic.bundle.js:56883)
at Object.switcher.render (ionic.bundle.js:54995)
at Object.switcher.init (ionic.bundle.js:54915)
at self.render (ionic.bundle.js:56743)
at self.register (ionic.bundle.js:56701)
at updateView (ionic.bundle.js:62357)

I am using the example of the nightly version and my ionic version is 1.2.4 我使用的是夜间版本的示例,我的离子版本是1.2.4

What worked for me was setting the effect option to a string because what we are doing (as written and copied from their docs) is passing it a variable named fade and of course we haven't defined it which explains the error. 对我有用的是将effect选项设置为字符串,因为我们正在做的事情(从他们的文档中编写和复制)是传递一个名为fade的变量,当然我们没有定义它来解释错误。

So change your code to 所以将代码更改为

$scope.options = {
        loop: false,
        effect: 'fade',
        speed: 500
    }

And it should work. 它应该工作。

Heres a list of other effects to try out as well :) slide or cube or coverflow 下面是一个其他效果的列表,以便尝试:) slidecubecoverflow

For better docs, the ion-slides in v2 is similar to v1: 对于更好的文档,v2中的ion-slides类似于v1:

https://ionicframework.com/docs/v2/api/components/slides/Slides/ https://ionicframework.com/docs/v2/api/components/slides/Slides/

ion-slides documentation gives a feeling that it is somewhat incomplete in ionic v1. ion-slides文档给出了一种感觉,它在离子v1中有些不完整。 To get the complete power of the new ion-slides component you need to check out the documentation from here 要获得新离子载玻片组件的全部功能,您需要从此处查看文档

If you look closely at the ion-slides tag you will see something like this slider="data.slider" . 如果仔细观察ion-slides标签,您会看到类似于slider =“data.slider”的内容

data.slider is the name of the slider. data.slider是滑块的名称。 You can use that with the methods mentioned in the above link to do powerful stuff. 您可以使用上面链接中提到的方法来执行强大的操作。 Like changing the slide index or adding a button to display the next slide. 喜欢更改幻灯片索引或添加按钮以显示下一张幻灯片。


Sample Method Usage 样本方法用法

$scope.slider = data.slider; $ scope.slider = data.slider;
$scope.slider.slideNext(); $ scope.slider.slideNext();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM