Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data中的startTime更新组件中的startTime未更新 #7

Open
Sam7Joker opened this issue Jun 27, 2018 · 2 comments
Open

data中的startTime更新组件中的startTime未更新 #7

Sam7Joker opened this issue Jun 27, 2018 · 2 comments

Comments

@Sam7Joker
Copy link

你好!我看到之前的提问,在created中直接更新startTime是有效的,但一旦使用ajax请求就无法更新startTime。我打印了组件的startTime确实没有更新。按照vue的逻辑,data更新了prop中的值不是也会更新吗?

@Gala-1024
Copy link
Owner

贴一下代码看看

@Sam7Joker
Copy link
Author

Sam7Joker commented Aug 28, 2018

<html lang="zh_CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>countdomwTest</title>
</head>
<body>
    <div id="app">
        <count-down :start-Time="startTime" :end-Time="endTime" v-on:start_callback="countDownS_cb(3)" v-on:end_callback="countDownE_cb(3)"></count-down>
    </div>
    <script src="Vue/vue.js"></script>
    <script src="vue2-countdown.js"></script>
    <script>
        var vm = new Vue({
            el: '#app',
            data:{
                callBk:'',
                currentTime:(new Date()).getTime(),
                startTime:( new Date() ).getTime()+(100*300),
                endTime:( new Date() ).getTime()+(500*500)
            },
            components: {
                'count-down': countdown,
            },
            mounted () {
                var self = this;
                 this.$nextTick(function(){
                     self.init();
                     console.log(this.startTime);
                 })
            },
            methods:{
                init () {
                    this.startTime =( new Date() ).getTime()+(500*300);
                },
                countDownS_cb:function(a){
                    console.log('callBack--'+a+'--开始倒计时结束回调');
                },
                countDownE_cb:function(a){
                    console.log('callBack--'+a+'--活动剩余倒计时结束回调');
                }
            },
        })
    </script>
</body>
</html>```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants