在安装时仅在vue中重新加载页面一次

时间:2018-05-07 12:09:49

标签: javascript vue.js vuejs2

当用户访问该页面时,我希望页面只刷新一次。

但是如果我将location.reload()放在mounted()中。它会触发无限循环页面重新加载

1 个答案:

答案 0 :(得分:9)

您只需要想出一种有条件地重新加载页面的方法,以避免无限重新加载。

一种方法是在本地存储中设置一个值:

    var message={"channelData":{
"text": "I hope the tour went well, Mr. Wonka.",
"response_type": "in_channel",
"attachments": [
{
    "text": "Who wins the lifetime supply of chocolate?",
    "fallback": "You could be telling the computer exactly what it can do with a lifetime supply of chocolate.",
    "color": "#3AA3E3",
    "attachment_type": "default",
    "callback_id": "select_simple_1234",
    "actions": [
        {
            "name": "winners_list",
            "text": "Who should win?",
            "type": "select",
            "data_source": "users"
        }
        ]
    }
]
}