菜鸟教程小白 发表于 2022-12-13 05:24:15

ios - 如何在 ionic 框架最新 beta 14 上同时使用选项卡和滑动菜单?


                                            <p><p>我正在寻找同时使用选项卡和滑动菜单的 ionic 应用程序的示例。是的,我遇到了几个示例,但其中大多数都已过时且无法使用最新的测试版。</p>

<p>比如这个:</p>

<p> <a href="http://tinyurl.com/sflowmotto1" rel="noreferrer noopener nofollow">http://tinyurl.com/sflowmotto1</a> </p>

<p>它适用于 14 测试版,但存在问题。我的客户不想滑动底部标签。</p>

<p>这个在 0.9.26 但不是 14 上工作得很好:</p>

<p> <a href="http://tinyurl.com/sflowmotto2" rel="noreferrer noopener nofollow">http://tinyurl.com/sflowmotto2</a> </p>

<pre><code>&lt;html ng-app=&#34;ionicApp&#34;&gt;
</code></pre>

<p>
   
    </p>

<pre><code>&lt;title&gt;Tabs and Slide-out menu Example&lt;/title&gt;

&lt;link href=&#34;http://code.ionicframework.com/0.9.26/css/ionic.min.css&#34; rel=&#34;stylesheet&#34;&gt;
&lt;script src=&#34;http://code.ionicframework.com/0.9.26/js/ionic.bundle.min.js&#34;&gt;&lt;/script&gt;
</code></pre>

<p></p>

<p></p>

<pre><code>&lt;div ng-controller=&#34;MainCtrl&#34;&gt;
&lt;ion-nav-view animation=&#34;slide-left-right&#34;&gt;&lt;/ion-nav-view&gt;
&lt;/div&gt;

&lt;script id=&#34;menu.html&#34; type=&#34;text/ng-template&#34;&gt;
&lt;ion-side-menus&gt;
    &lt;ion-pane ion-side-menu-content&gt;
         &lt;ion-nav-bar animation=&#34;nav-title-slide-ios7&#34;
         type=&#34;bar-positive&#34;
         left-buttons=&#34;leftButtons&#34;
         back-button-type=&#34;button-icon&#34;
         back-button-icon=&#34;ion-arrow-left-c&#34;&gt;&lt;/ion-nav-bar&gt;
      &lt;ion-nav-view name=&#34;menu-content&#34;&gt;&lt;/ion-nav-view&gt;
    &lt;/ion-pane&gt;
    &lt;ion-side-menu side=&#34;left&#34;&gt;
      &lt;ion-content&gt;
      &lt;ul class=&#34;list&#34;&gt;
          &lt;a href=&#34;#/main/tab/home&#34; class=&#34;item&#34; ng-click=&#34;mainCtrl.showFeature = false&#34;&gt;Home&lt;/a&gt;
          &lt;a href=&#34;#/main/tab/about&#34; class=&#34;item&#34;ng-click=&#34;mainCtrl.showFeature = false&#34;&gt;About&lt;/a&gt;
          &lt;a href=&#34;#/main/tab/contact&#34; class=&#34;item&#34;ng-click=&#34;mainCtrl.showFeature = fakse&#34;&gt;Contact&lt;/a&gt;
          &lt;a href=&#34;#/main/tab/feature&#34; class=&#34;item&#34; ng-click=&#34;mainCtrl.showFeature = true&#34;&gt;Feature&lt;/a&gt;
      &lt;/ul&gt;
      &lt;/ion-content&gt;
    &lt;/ion-side-menu&gt;
&lt;/ion-side-menus&gt;   
&lt;/script&gt;

&lt;script id=&#34;tabs.html&#34; type=&#34;text/ng-template&#34;&gt;
&lt;ion-tabs tabs-style=&#34;tabs-icon-top&#34; tabs-type=&#34;tabs-positive&#34;&gt;

    &lt;ion-tab title=&#34;Home&#34; icon=&#34;ion-home&#34; href=&#34;#/main/tab/home&#34;&gt;
      &lt;ion-nav-view name=&#34;home-tab&#34;&gt;&lt;/ion-nav-view&gt;
    &lt;/ion-tab&gt;

    &lt;ion-tab title=&#34;About&#34; icon=&#34;ion-ios7-information&#34; href=&#34;#/main/tab/about&#34;&gt;
      &lt;ion-nav-view name=&#34;about-tab&#34;&gt;&lt;/ion-nav-view&gt;
    &lt;/ion-tab&gt;

    &lt;ion-tab title=&#34;Contact&#34; icon=&#34;ion-ios7-world&#34; ui-sref=&#34;main.tabs.contact&#34;&gt;
      &lt;ion-nav-view name=&#34;contact-tab&#34;&gt;&lt;/ion-nav-view&gt;
    &lt;/ion-tab&gt;

    &lt;ion-tab title=&#34;Feature&#34; icon=&#34;ion-ios7-world&#34; ui-sref=&#34;main.tabs.feature&#34; ng-if=&#34;mainCtrl.showFeature&#34;&gt;
      &lt;ion-nav-view name=&#34;feature-tab&#34;&gt;&lt;/ion-nav-view&gt;
    &lt;/ion-tab&gt;

&lt;/ion-tabs&gt;
&lt;/script&gt;

&lt;script id=&#34;home.html&#34; type=&#34;text/ng-template&#34;&gt;
&lt;ion-view title=&#34;&#39;Home&#39;&#34; left-buttons=&#34;leftButtons&#34;&gt;
    &lt;ion-content has-header=&#34;true&#34; padding=&#34;true&#34; &gt;
      &lt;p&gt;Example of Ionic tabs. Navigate to each tab, and
      navigate to child views of each tab and notice how
      each tab has its own navigation history.&lt;/p&gt;
      &lt;p&gt;
      &lt;a class=&#34;button icon icon-right ion-chevron-right&#34; href=&#34;#/main/tab/facts&#34;&gt;Scientific Facts&lt;/a&gt;
      &lt;/p&gt;
      &lt;p&gt;This next button navigates to a view that does not have a tab or present
    &lt;/ion-content&gt;
&lt;/ion-view&gt;
&lt;/script&gt;

&lt;script id=&#34;facts.html&#34; type=&#34;text/ng-template&#34; &gt;
&lt;ion-view title=&#34;&#39;Facts&#39;&#34; left-buttons=&#34;leftButtons&#34;&gt;
    &lt;ion-content has-header=&#34;true&#34; padding=&#34;true&#34;&gt;
      &lt;p&gt;Banging your head against a wall uses 150 calories an hour.&lt;/p&gt;
      &lt;p&gt;Dogs have four toes on their hind feet, and five on their front feet.&lt;/p&gt;
      &lt;p&gt;The ant can lift 50 times its own weight, can pull 30 times its own weight and always falls over on its right side when intoxicated.&lt;/p&gt;
      &lt;p&gt;A cockroach will live nine days without it&#39;s head, before it starves to death.&lt;/p&gt;
      &lt;p&gt;Polar bears are left handed.&lt;/p&gt;
      &lt;p&gt;
      &lt;a class=&#34;button icon ion-home&#34; href=&#34;#/main/tab/home&#34;&gt; Home&lt;/a&gt;
      &lt;a class=&#34;button icon icon-right ion-chevron-right&#34; href=&#34;#/main/tab/facts2&#34;&gt;More Facts&lt;/a&gt;
      &lt;/p&gt;
    &lt;/ion-content&gt;
&lt;/ion-view&gt;
&lt;/script&gt;

&lt;script id=&#34;facts2.html&#34; type=&#34;text/ng-template&#34; &gt;
&lt;ion-view title=&#34;&#39;Also Factual&#39;&#34; left-buttons=&#34;leftButtons&#34;&gt;
    &lt;ion-content has-header=&#34;true&#34; padding=&#34;true&#34;&gt;
      &lt;p&gt;111,111,111 x 111,111,111 = 12,345,678,987,654,321&lt;/p&gt;
      &lt;p&gt;1 in every 4 Americans has appeared on T.V.&lt;/p&gt;
      &lt;p&gt;11% of the world is left-handed.&lt;/p&gt;
      &lt;p&gt;1 in 8 Americans has worked at a McDonalds restaurant.&lt;/p&gt;
      &lt;p&gt;$283,200 is the absolute highest amount of money you can win on Jeopardy.&lt;/p&gt;
      &lt;p&gt;101 Dalmatians, Peter Pan, Lady and the Tramp, and Mulan are the only Disney cartoons where both parents are present and don&#39;t die throughout the movie.&lt;/p&gt;
      &lt;p&gt;
      &lt;a class=&#34;button icon ion-home&#34; href=&#34;#/main/tab/home&#34;&gt; Home&lt;/a&gt;
      &lt;a class=&#34;button icon ion-chevron-left&#34; href=&#34;#/main/tab/facts&#34;&gt; Scientific Facts&lt;/a&gt;
      &lt;/p&gt;
    &lt;/ion-content&gt;
&lt;/ion-view&gt;
&lt;/script&gt;

&lt;script id=&#34;about.html&#34; type=&#34;text/ng-template&#34;&gt;
&lt;ion-view title=&#34;&#39;About&#39;&#34; left-buttons=&#34;leftButtons&#34;&gt;
    &lt;ion-content has-header=&#34;true&#34; padding=&#34;true&#34;&gt;
      &lt;h3&gt;Create hybrid mobile apps with the web technologies you love.&lt;/h3&gt;
      &lt;p&gt;Free and open source, Ionic offers a library of mobile-optimized HTML, CSS and JS components for building highly interactive apps.&lt;/p&gt;
      &lt;p&gt;Built with Sass and optimized for AngularJS.&lt;/p&gt;
      &lt;p&gt;
      &lt;a class=&#34;button icon icon-right ion-chevron-right&#34; href=&#34;#/main/tab/navstack&#34;&gt;Tabs Nav Stack&lt;/a&gt;
      &lt;/p&gt;
    &lt;/ion-content&gt;
&lt;/ion-view&gt;
&lt;/script&gt;

&lt;script id=&#34;nav-stack.html&#34; type=&#34;text/ng-template&#34;&gt;
&lt;ion-view title=&#34;&#39;Tab Nav Stack&#39;&#34; left-buttons=&#34;leftButtons&#34;&gt;
    &lt;ion-content has-header=&#34;true&#34; padding=&#34;true&#34;&gt;
      &lt;p&gt;&lt;img src=&#34;http://ionicframework.com/img/diagrams/tabs-nav-stack.png&#34; style=&#34;width:100%&#34;&gt;&lt;/p&gt;
    &lt;/ion-content&gt;
&lt;/ion-view&gt;
&lt;/script&gt;

&lt;script id=&#34;contact.html&#34; type=&#34;text/ng-template&#34;&gt;
&lt;ion-view title=&#34;&#39;Contact&#39;&#34; left-buttons=&#34;leftButtons&#34;&gt;
    &lt;ion-content has-header=&#34;true&#34; padding=&#34;true&#34;&gt;
      &lt;p&gt;@IonicFramework&lt;/p&gt;
      &lt;p&gt;@DriftyCo&lt;/p&gt;
    &lt;/ion-content&gt;
&lt;/ion-view&gt;
&lt;/script&gt;

&lt;script id=&#34;feature.html&#34; type=&#34;text/ng-template&#34;&gt;
&lt;ion-view title=&#34;&#39;Feature&#39;&#34; left-buttons=&#34;leftButtons&#34;&gt;
    &lt;ion-content has-header=&#34;true&#34; padding=&#34;true&#34;&gt;
      This is a feature pane that does not require a visible tab button.
    &lt;/ion-content&gt;
&lt;/ion-view&gt;
&lt;/script&gt;
</code></pre>

<p>
</p>

<pre><code>body {
cursor: url(&#39;http://ionicframework.com/img/finger.png&#39;), auto;
}


angular.module(&#39;ionicApp&#39;, [&#39;ionic&#39;])

.config(function($stateProvider, $urlRouterProvider) {

$stateProvider

    .state(&#39;main&#39;, {
      url: &#34;/main&#34;,
      abstract: true,
      templateUrl: &#34;menu.html&#34;
    })

    .state(&#39;main.tabs&#39;, {
      url: &#34;/tab&#34;,
      abstract: true,
      views: {
      &#39;menu-content&#39;: {
          templateUrl: &#34;tabs.html&#34;,
      }
      }
    })
    .state(&#39;main.tabs.home&#39;, {
      url: &#34;/home&#34;,
      views: {
      &#39;home-tab&#39;: {
          templateUrl: &#34;home.html&#34;,
          controller: &#39;HomeTabCtrl&#39;
      }
      }
    })
    .state(&#39;main.tabs.facts&#39;, {
      url: &#34;/facts&#34;,
      views: {
      &#39;home-tab&#39;: {
          templateUrl: &#34;facts.html&#34;
      }
      }
    })
    .state(&#39;main.tabs.facts2&#39;, {
      url: &#34;/facts2&#34;,
      views: {
      &#39;home-tab&#39;: {
          templateUrl: &#34;facts2.html&#34;
      }
      }
    })
    .state(&#39;main.tabs.about&#39;, {
      url: &#34;/about&#34;,
      views: {
      &#39;about-tab&#39;: {
          templateUrl: &#34;about.html&#34;
      }
      }
    })

    .state(&#39;main.tabs.feature&#39;, {
      url: &#34;/feature&#34;,
      views: {
      &#39;feature-tab&#39;: {
          templateUrl: &#34;feature.html&#34;
      }
      }
    })

.state(&#39;main.tabs.navstack&#39;, {
      url: &#34;/navstack&#34;,
      views: {
      &#39;about-tab&#39;: {
          templateUrl: &#34;nav-stack.html&#34;
      }
      }
    })
    .state(&#39;main.tabs.contact&#39;, {
      url: &#34;/contact&#34;,
      views: {
      &#39;contact-tab&#39;: {
          templateUrl: &#34;contact.html&#34;
      }
      }
    })
    .state(&#39;main.feature&#39;, {
      url: &#34;/feature&#34;,
      views: {
      &#39;menu-content&#39;: {
          templateUrl: &#34;feature.html&#34;
      }
      }
    });


   $urlRouterProvider.otherwise(&#34;/main/tab/home&#34;);

})

.controller(&#39;HomeTabCtrl&#39;, function($scope) {
console.log(&#39;HomeTabCtrl&#39;);
})

.controller(&#39;MainCtrl&#39;, function($scope, $ionicSideMenuDelegate) {

$scope.mainCtrl = {};
$scope.leftButtons = [{
    type: &#39;button-icon button-clear ion-navicon&#39;,
    tap: function(e) {
      $ionicSideMenuDelegate.toggleLeft($scope.$$childHead);
    }
}];

$scope.mainCtrl.showFeature = false;

});
</code></pre>

<p>我很好奇为什么第二个示例不适用于 beta 14?</p>

<p>这里是损坏版本的链接,一些图标和动画丢失了:</p>

<p> <a href="http://codepen.io/anon/pen/RNMNQb" rel="noreferrer noopener nofollow">http://codepen.io/anon/pen/RNMNQb</a> </p>

<p>编辑:由于新版本的新变化,问题与以前的问题不同。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>根据 beta 14 <a href="https://github.com/driftyco/ionic/releases" rel="noreferrer noopener nofollow">https://github.com/driftyco/ionic/releases</a> </p>

<blockquote>
<p>Breaking Changes:</p>

<p>Animation CSS: The CSS for view transitions have changed. This is a
breaking change only if Ionic apps had customized Ionic’s animation
CSS. Additionally, all keyframe animations were removed since they
weren&#39;t being used. (20Kb saved!)</p>
</blockquote>

<p>此代码示例已被弃用:</p>

<pre><code>&lt;ion-nav-view animation=&#34;slide-left-right&#34;&gt;
</code></pre>

<p>我仍在寻找解决方案,我一直在寻找 10 小时,我希望我的标签能够动画:'(</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 如何在 ionic 框架最新 beta 14 上同时使用选项卡和滑动菜单?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/28563509/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/28563509/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 如何在 ionic 框架最新 beta 14 上同时使用选项卡和滑动菜单?