简体   繁体   English

Polymer动画页面无法更改页面

[英]Polymer animated-pages can't change page

I can't change the page when i click the button in the logincard element. 单击logincard元素中的按钮时,无法更改页面。 In the logincard element i have set the button's on-tap to {{onSignUp}} 在logincard元素中,我将按钮的点击设置为{{onSignUp}}

What should i do? 我该怎么办? I get the error message: Uncaught TypeError: Cannot read property 'selected' of null 我收到错误消息:未捕获的TypeError:无法读取null的“已选择”属性

    <core-animated-pages id = "animatedPages" transitions="cross-fade" selected="{{moveCard}}" center >
        <section id="0">
            <div hero-id="hero" hero>
                <moha-logincard token="{{token}}" success="{{success}}" loginurl="{{loginurl}}" signup="{{signup}}" z="{{z}}" onLogin="{{close}}" onSignUp="{{goToSignUp}}">
                </moha-logincard>
            </div>
        </section>
        <section id="1">
            <div  hero-id="hero" hero>
                <moha-signupcard success="{{success}}" signupurl="{{signupurl}}" z="{{z}}" onSignUp="{{backToLogin}}"></moha-signupcard>
            </div></section>

    </core-animated-pages>
</template>

<script>
    Polymer('moha-login-page', {
        moveCard: "0",
        pages:document.querySelector('core-animated-pages'),
        signup: false,
        token: "",
        loginurl: "",
        signupurl: "",
        z: 2,
        close: function () {
            //dialógus becsukása ha van
        },
        goToSignUp: function () {
            // var pages = document.querySelector('core-animated-pages');
            //var pages = this.$.animatedPages;
            this.pages = document.querySelector('core-animated-pages');
           console.log(this.pages.selected);

            this.moveCard = "1";
            this.pages.selected = this.moveCard;
           console.log(this.pages.selected);

        },
        backToLogin: function () {
            this.moveCard = 0;
        }
    });
</script>

While I have no experience with core-animated-pages I highly doubt that 虽然我没有使用core-animated-pages经验,但我对此表示高度怀疑

this.pages = document.querySelector('core-animated-pages');

will get you what you desire as the element may live in shadow DOM. 将获得您想要的东西,因为该元素可能存在于影子DOM中。

Try 尝试
this.pages = document.querySelectorAll('html /deep/ core-animated-pages');

and see if this solves your TypeError. 看看这是否能解决您的TypeError问题。

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

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