[SOLVED] Define the object 'view' in a template

Hello,

Am trying to reload the page using the code below in one of my templates.

view.router.navigate(view.router.currentRoute.url, {
	ignoreCache  : true,
	reloadCurrent : true
});

But I get the error view is undefined.

How is the view object defined again?

what is view? your f7 instance? where are you using that code?

Hello @pvtallulah

This is my code

 <template>
  <div class="page">
   
   
  </div>
</template>
<script>

	return {
		data: function() {
						
			
		},
		methods: {
			
			
			refreshPage: function () {
								
				var self = this;
			
				//
				view.router.navigate(view.router.currentRoute.url, {
					ignoreCache  : true,
					reloadCurrent : true
				})

				
			},
			
		},	
		on: {
			pageBeforeRemove: function () {
				
				var self = this;

				
			},
			pageAfterIn: function() {
			
				var self = this;
												
				
			},
			pageMounted: function() {
			
				var self = this;
												
			},
			pageInit: function() {
				
				var self = this;
				
				
			}
		}
	}	
	
</script>

How do I use it?

Ah!. I have just noticed that I am using

var mainView = app.views.create('.view-main',{url: '/'});

and not

var view = app.views.create('.view-main',{url: '/'});

Its good now. Thanks @pvtallulah for the pointers.

1 Like