Best way to re-render v-for when I change my route in vue.js or without reload page manualWhat’s the best way to reload / refresh an iframe?Best way to detect when a user leaves a web page?How do I modify the URL without reloading the page?Is there an easy way to reload css without reloading the page?Updating address bar with new URL without hash or reloading the pageHow to reload or re-render the entire page using AngularJSChanging route doesn't scroll to top in the new pageCan you force Vue.js to reload/re-render?error when rendering routes in vue.jsMutations not registering using computed properties in Vuex
How were these pictures of spacecraft wind tunnel testing taken?
Which is the common name of Mind Flayers?
Why are C64 games inconsistent with which joystick port they use?
Approximate solution : factorial and exponentials
Is there a down side to setting the sampling time of a SAR ADC as long as possible?
Why is this Simple Puzzle impossible to solve?
What do different value notes on the same line mean?
Dictionary size reduces upon increasing one element
How strong are Wi-Fi signals?
Python program to convert a 24 hour format to 12 hour format
How does an ARM MCU run faster than the external crystal?
Boss wants me to falsify a report. How should I document this unethical demand?
At what point in European history could a government build a printing press given a basic description?
Looking for a soft substance that doesn't dissolve underwater
analysis of BJT PNP type - why they can use voltage divider?
Is there an efficient way to replace text matching the entire content of one file with the entire content of another file?
Should I disclose a colleague's illness (that I should not know about) when others badmouth him
If a person had control of every single cell of their body, would they be able to transform into another creature?
Where is the logic in castrating fighters?
Were pens caps holes designed to prevent death by suffocation if swallowed?
What is the largest (size) solid object ever dropped from an airplane to impact the ground in freefall?
Four-in-a-line Puzzle
What is the difference between “/private/var/vm” and “/vm”?
How can people dance around bonfires on Lag Lo'Omer - it's darchei emori?
Best way to re-render v-for when I change my route in vue.js or without reload page manual
What’s the best way to reload / refresh an iframe?Best way to detect when a user leaves a web page?How do I modify the URL without reloading the page?Is there an easy way to reload css without reloading the page?Updating address bar with new URL without hash or reloading the pageHow to reload or re-render the entire page using AngularJSChanging route doesn't scroll to top in the new pageCan you force Vue.js to reload/re-render?error when rendering routes in vue.jsMutations not registering using computed properties in Vuex
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
How the best way to re-render v-for in my application when I change/move to another route in vue js?
In my case I use vuex
, vuex-persistedstate
and moment
for save localStorage and show a moment ago
time.
But how to use rerender v-for without data changes from my API
and reload page manual?
If you see
Recent Activity data always cache in localStorage
. But if no new data from api, how to make this always become 3 minutes ago
then 4 minutes ago
etc....
It happend only if I reload the page. Because my code like
<template>
<div class="widget">
<h4 class="widget-title">Recent Activity</h4>
<ul class="activitiez">
<li v-for="act in recentActivity" :key="act._id" :id="act._id">
<div class="activity-meta">
<i v-html="convertToMoment(act.created_at)"></i>
<span v-html="act.activity"></span>
<h6>by <a href="#" v-html="act.sent_name"></a></h6>
</div>
</li>
</ul>
</div>
</template>
<script>
import mapGetters, mapActions from "vuex"
export default
created()
this.fetchRecentActivityData()
,
computed:
...mapGetters(["recentActivity"])
,
methods:
...mapActions(["fetchRecentActivityData"]),
convertToMoment(data)
return moment(data).fromNow()
,
</script>
<style>
</style>
and my store code
import axios from 'axios';
const state =
recentActivityStore: [],
errorBag: null,
timingStore: Date.now()
;
const getters =
recentActivity: state => state.recentActivityStore,
recentActivityTiming: state => state.timingStore
;
const actions =
async fetchRecentActivityData( commit )
const recentAct = this.state.recentactivity.recentActivityStore
if(_.isEmpty(recentAct))
const response = await axios.get('/recent/activity')
commit('UPDATE_RECENT_ACTIVITY', response.data)
commit('UPDATE_TIMING', Date.now())
;
const mutations =
UPDATE_RECENT_ACTIVITY: (state, data) =>
state.recentActivityStore = data
,
UPDATE_TIMING: (state, data) =>
state.timingStore = data
;
export default
state,
getters,
actions,
mutations
;
How to make my v-for
reload without refresh page manual? Then 3 minutes ago
then 4 minutes ago
happened
Thanks
javascript vue.js
add a comment |
How the best way to re-render v-for in my application when I change/move to another route in vue js?
In my case I use vuex
, vuex-persistedstate
and moment
for save localStorage and show a moment ago
time.
But how to use rerender v-for without data changes from my API
and reload page manual?
If you see
Recent Activity data always cache in localStorage
. But if no new data from api, how to make this always become 3 minutes ago
then 4 minutes ago
etc....
It happend only if I reload the page. Because my code like
<template>
<div class="widget">
<h4 class="widget-title">Recent Activity</h4>
<ul class="activitiez">
<li v-for="act in recentActivity" :key="act._id" :id="act._id">
<div class="activity-meta">
<i v-html="convertToMoment(act.created_at)"></i>
<span v-html="act.activity"></span>
<h6>by <a href="#" v-html="act.sent_name"></a></h6>
</div>
</li>
</ul>
</div>
</template>
<script>
import mapGetters, mapActions from "vuex"
export default
created()
this.fetchRecentActivityData()
,
computed:
...mapGetters(["recentActivity"])
,
methods:
...mapActions(["fetchRecentActivityData"]),
convertToMoment(data)
return moment(data).fromNow()
,
</script>
<style>
</style>
and my store code
import axios from 'axios';
const state =
recentActivityStore: [],
errorBag: null,
timingStore: Date.now()
;
const getters =
recentActivity: state => state.recentActivityStore,
recentActivityTiming: state => state.timingStore
;
const actions =
async fetchRecentActivityData( commit )
const recentAct = this.state.recentactivity.recentActivityStore
if(_.isEmpty(recentAct))
const response = await axios.get('/recent/activity')
commit('UPDATE_RECENT_ACTIVITY', response.data)
commit('UPDATE_TIMING', Date.now())
;
const mutations =
UPDATE_RECENT_ACTIVITY: (state, data) =>
state.recentActivityStore = data
,
UPDATE_TIMING: (state, data) =>
state.timingStore = data
;
export default
state,
getters,
actions,
mutations
;
How to make my v-for
reload without refresh page manual? Then 3 minutes ago
then 4 minutes ago
happened
Thanks
javascript vue.js
1
Please don't upload images of code. They can't be copied to create a solution, aren't searchable for future readers and harder to read than text. Please post the actual code as text to create a minimal reproducible example.
– adiga
Mar 24 at 6:57
Sorry @adiga already changed
– Bertho Joris
Mar 24 at 7:08
I thought you can register a setInterval to update your data time per minutes.
– bcjohn
Mar 24 at 7:23
what if no data has changed at all? will not trigered changes on the screen
– Bertho Joris
Mar 24 at 7:32
add a comment |
How the best way to re-render v-for in my application when I change/move to another route in vue js?
In my case I use vuex
, vuex-persistedstate
and moment
for save localStorage and show a moment ago
time.
But how to use rerender v-for without data changes from my API
and reload page manual?
If you see
Recent Activity data always cache in localStorage
. But if no new data from api, how to make this always become 3 minutes ago
then 4 minutes ago
etc....
It happend only if I reload the page. Because my code like
<template>
<div class="widget">
<h4 class="widget-title">Recent Activity</h4>
<ul class="activitiez">
<li v-for="act in recentActivity" :key="act._id" :id="act._id">
<div class="activity-meta">
<i v-html="convertToMoment(act.created_at)"></i>
<span v-html="act.activity"></span>
<h6>by <a href="#" v-html="act.sent_name"></a></h6>
</div>
</li>
</ul>
</div>
</template>
<script>
import mapGetters, mapActions from "vuex"
export default
created()
this.fetchRecentActivityData()
,
computed:
...mapGetters(["recentActivity"])
,
methods:
...mapActions(["fetchRecentActivityData"]),
convertToMoment(data)
return moment(data).fromNow()
,
</script>
<style>
</style>
and my store code
import axios from 'axios';
const state =
recentActivityStore: [],
errorBag: null,
timingStore: Date.now()
;
const getters =
recentActivity: state => state.recentActivityStore,
recentActivityTiming: state => state.timingStore
;
const actions =
async fetchRecentActivityData( commit )
const recentAct = this.state.recentactivity.recentActivityStore
if(_.isEmpty(recentAct))
const response = await axios.get('/recent/activity')
commit('UPDATE_RECENT_ACTIVITY', response.data)
commit('UPDATE_TIMING', Date.now())
;
const mutations =
UPDATE_RECENT_ACTIVITY: (state, data) =>
state.recentActivityStore = data
,
UPDATE_TIMING: (state, data) =>
state.timingStore = data
;
export default
state,
getters,
actions,
mutations
;
How to make my v-for
reload without refresh page manual? Then 3 minutes ago
then 4 minutes ago
happened
Thanks
javascript vue.js
How the best way to re-render v-for in my application when I change/move to another route in vue js?
In my case I use vuex
, vuex-persistedstate
and moment
for save localStorage and show a moment ago
time.
But how to use rerender v-for without data changes from my API
and reload page manual?
If you see
Recent Activity data always cache in localStorage
. But if no new data from api, how to make this always become 3 minutes ago
then 4 minutes ago
etc....
It happend only if I reload the page. Because my code like
<template>
<div class="widget">
<h4 class="widget-title">Recent Activity</h4>
<ul class="activitiez">
<li v-for="act in recentActivity" :key="act._id" :id="act._id">
<div class="activity-meta">
<i v-html="convertToMoment(act.created_at)"></i>
<span v-html="act.activity"></span>
<h6>by <a href="#" v-html="act.sent_name"></a></h6>
</div>
</li>
</ul>
</div>
</template>
<script>
import mapGetters, mapActions from "vuex"
export default
created()
this.fetchRecentActivityData()
,
computed:
...mapGetters(["recentActivity"])
,
methods:
...mapActions(["fetchRecentActivityData"]),
convertToMoment(data)
return moment(data).fromNow()
,
</script>
<style>
</style>
and my store code
import axios from 'axios';
const state =
recentActivityStore: [],
errorBag: null,
timingStore: Date.now()
;
const getters =
recentActivity: state => state.recentActivityStore,
recentActivityTiming: state => state.timingStore
;
const actions =
async fetchRecentActivityData( commit )
const recentAct = this.state.recentactivity.recentActivityStore
if(_.isEmpty(recentAct))
const response = await axios.get('/recent/activity')
commit('UPDATE_RECENT_ACTIVITY', response.data)
commit('UPDATE_TIMING', Date.now())
;
const mutations =
UPDATE_RECENT_ACTIVITY: (state, data) =>
state.recentActivityStore = data
,
UPDATE_TIMING: (state, data) =>
state.timingStore = data
;
export default
state,
getters,
actions,
mutations
;
How to make my v-for
reload without refresh page manual? Then 3 minutes ago
then 4 minutes ago
happened
Thanks
javascript vue.js
javascript vue.js
edited Mar 24 at 7:07
Bertho Joris
asked Mar 24 at 6:38
Bertho JorisBertho Joris
60121341
60121341
1
Please don't upload images of code. They can't be copied to create a solution, aren't searchable for future readers and harder to read than text. Please post the actual code as text to create a minimal reproducible example.
– adiga
Mar 24 at 6:57
Sorry @adiga already changed
– Bertho Joris
Mar 24 at 7:08
I thought you can register a setInterval to update your data time per minutes.
– bcjohn
Mar 24 at 7:23
what if no data has changed at all? will not trigered changes on the screen
– Bertho Joris
Mar 24 at 7:32
add a comment |
1
Please don't upload images of code. They can't be copied to create a solution, aren't searchable for future readers and harder to read than text. Please post the actual code as text to create a minimal reproducible example.
– adiga
Mar 24 at 6:57
Sorry @adiga already changed
– Bertho Joris
Mar 24 at 7:08
I thought you can register a setInterval to update your data time per minutes.
– bcjohn
Mar 24 at 7:23
what if no data has changed at all? will not trigered changes on the screen
– Bertho Joris
Mar 24 at 7:32
1
1
Please don't upload images of code. They can't be copied to create a solution, aren't searchable for future readers and harder to read than text. Please post the actual code as text to create a minimal reproducible example.
– adiga
Mar 24 at 6:57
Please don't upload images of code. They can't be copied to create a solution, aren't searchable for future readers and harder to read than text. Please post the actual code as text to create a minimal reproducible example.
– adiga
Mar 24 at 6:57
Sorry @adiga already changed
– Bertho Joris
Mar 24 at 7:08
Sorry @adiga already changed
– Bertho Joris
Mar 24 at 7:08
I thought you can register a setInterval to update your data time per minutes.
– bcjohn
Mar 24 at 7:23
I thought you can register a setInterval to update your data time per minutes.
– bcjohn
Mar 24 at 7:23
what if no data has changed at all? will not trigered changes on the screen
– Bertho Joris
Mar 24 at 7:32
what if no data has changed at all? will not trigered changes on the screen
– Bertho Joris
Mar 24 at 7:32
add a comment |
1 Answer
1
active
oldest
votes
Codepen : https://codepen.io/anon/pen/qvgxRJ
To solve this create a vue filter
. Code : Vuejs time ago filter
filters:
timeago: function (pdate, ctime)
,
apply this filter in HTML
<i>act.created_at </i>
It calculates the time ago based on current time. Then in setInterval update the currenttime every 50 seconds. It will update the component every 50 seconds.
data:()=>(
currenttime: Date.now(),
timer: ''
),
created()
this.fetchRecentActivityData()
this.timer = setInterval(() => this.currenttime = Date.now(), 50000);
Final Code.
export default
data:()=>(
currenttime: Date.now(),
timer: ''
),
filters:
timeago: function (pdate, ctime)
,
created()
this.fetchRecentActivityData()
this.timer = setInterval(() => this.currenttime = Date.now(), 50000);
,
beforeDestroy()
clearInterval(this.timer)
,
computed:
...mapGetters(["recentActivity"])
,
methods:
...mapActions(["fetchRecentActivityData"]),
,
in HTML
<li v-for="act in recentActivity" :key="act._id" :id="act._id">
<div class="activity-meta">
<i>act.created_at </i>
<span v-html="act.activity"></span>
<h6>by <a href="#" v-html="act.sent_name"></a></h6>
</div>
</li>
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55321326%2fbest-way-to-re-render-v-for-when-i-change-my-route-in-vue-js-or-without-reload-p%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Codepen : https://codepen.io/anon/pen/qvgxRJ
To solve this create a vue filter
. Code : Vuejs time ago filter
filters:
timeago: function (pdate, ctime)
,
apply this filter in HTML
<i>act.created_at </i>
It calculates the time ago based on current time. Then in setInterval update the currenttime every 50 seconds. It will update the component every 50 seconds.
data:()=>(
currenttime: Date.now(),
timer: ''
),
created()
this.fetchRecentActivityData()
this.timer = setInterval(() => this.currenttime = Date.now(), 50000);
Final Code.
export default
data:()=>(
currenttime: Date.now(),
timer: ''
),
filters:
timeago: function (pdate, ctime)
,
created()
this.fetchRecentActivityData()
this.timer = setInterval(() => this.currenttime = Date.now(), 50000);
,
beforeDestroy()
clearInterval(this.timer)
,
computed:
...mapGetters(["recentActivity"])
,
methods:
...mapActions(["fetchRecentActivityData"]),
,
in HTML
<li v-for="act in recentActivity" :key="act._id" :id="act._id">
<div class="activity-meta">
<i>act.created_at </i>
<span v-html="act.activity"></span>
<h6>by <a href="#" v-html="act.sent_name"></a></h6>
</div>
</li>
add a comment |
Codepen : https://codepen.io/anon/pen/qvgxRJ
To solve this create a vue filter
. Code : Vuejs time ago filter
filters:
timeago: function (pdate, ctime)
,
apply this filter in HTML
<i>act.created_at </i>
It calculates the time ago based on current time. Then in setInterval update the currenttime every 50 seconds. It will update the component every 50 seconds.
data:()=>(
currenttime: Date.now(),
timer: ''
),
created()
this.fetchRecentActivityData()
this.timer = setInterval(() => this.currenttime = Date.now(), 50000);
Final Code.
export default
data:()=>(
currenttime: Date.now(),
timer: ''
),
filters:
timeago: function (pdate, ctime)
,
created()
this.fetchRecentActivityData()
this.timer = setInterval(() => this.currenttime = Date.now(), 50000);
,
beforeDestroy()
clearInterval(this.timer)
,
computed:
...mapGetters(["recentActivity"])
,
methods:
...mapActions(["fetchRecentActivityData"]),
,
in HTML
<li v-for="act in recentActivity" :key="act._id" :id="act._id">
<div class="activity-meta">
<i>act.created_at </i>
<span v-html="act.activity"></span>
<h6>by <a href="#" v-html="act.sent_name"></a></h6>
</div>
</li>
add a comment |
Codepen : https://codepen.io/anon/pen/qvgxRJ
To solve this create a vue filter
. Code : Vuejs time ago filter
filters:
timeago: function (pdate, ctime)
,
apply this filter in HTML
<i>act.created_at </i>
It calculates the time ago based on current time. Then in setInterval update the currenttime every 50 seconds. It will update the component every 50 seconds.
data:()=>(
currenttime: Date.now(),
timer: ''
),
created()
this.fetchRecentActivityData()
this.timer = setInterval(() => this.currenttime = Date.now(), 50000);
Final Code.
export default
data:()=>(
currenttime: Date.now(),
timer: ''
),
filters:
timeago: function (pdate, ctime)
,
created()
this.fetchRecentActivityData()
this.timer = setInterval(() => this.currenttime = Date.now(), 50000);
,
beforeDestroy()
clearInterval(this.timer)
,
computed:
...mapGetters(["recentActivity"])
,
methods:
...mapActions(["fetchRecentActivityData"]),
,
in HTML
<li v-for="act in recentActivity" :key="act._id" :id="act._id">
<div class="activity-meta">
<i>act.created_at </i>
<span v-html="act.activity"></span>
<h6>by <a href="#" v-html="act.sent_name"></a></h6>
</div>
</li>
Codepen : https://codepen.io/anon/pen/qvgxRJ
To solve this create a vue filter
. Code : Vuejs time ago filter
filters:
timeago: function (pdate, ctime)
,
apply this filter in HTML
<i>act.created_at </i>
It calculates the time ago based on current time. Then in setInterval update the currenttime every 50 seconds. It will update the component every 50 seconds.
data:()=>(
currenttime: Date.now(),
timer: ''
),
created()
this.fetchRecentActivityData()
this.timer = setInterval(() => this.currenttime = Date.now(), 50000);
Final Code.
export default
data:()=>(
currenttime: Date.now(),
timer: ''
),
filters:
timeago: function (pdate, ctime)
,
created()
this.fetchRecentActivityData()
this.timer = setInterval(() => this.currenttime = Date.now(), 50000);
,
beforeDestroy()
clearInterval(this.timer)
,
computed:
...mapGetters(["recentActivity"])
,
methods:
...mapActions(["fetchRecentActivityData"]),
,
in HTML
<li v-for="act in recentActivity" :key="act._id" :id="act._id">
<div class="activity-meta">
<i>act.created_at </i>
<span v-html="act.activity"></span>
<h6>by <a href="#" v-html="act.sent_name"></a></h6>
</div>
</li>
edited Mar 31 at 0:06
answered Mar 24 at 8:27
dagaltidagalti
762137
762137
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55321326%2fbest-way-to-re-render-v-for-when-i-change-my-route-in-vue-js-or-without-reload-p%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Please don't upload images of code. They can't be copied to create a solution, aren't searchable for future readers and harder to read than text. Please post the actual code as text to create a minimal reproducible example.
– adiga
Mar 24 at 6:57
Sorry @adiga already changed
– Bertho Joris
Mar 24 at 7:08
I thought you can register a setInterval to update your data time per minutes.
– bcjohn
Mar 24 at 7:23
what if no data has changed at all? will not trigered changes on the screen
– Bertho Joris
Mar 24 at 7:32