[Vuejs]-Check URL $route param value using v-if in vue js

0👍

<v-app v-if="url.indexOf('http://127.0.0.1:8000/setting') > -1 ? true : false">

if there it is inclue ‘http://127.0.0.1:8000/setting’ return true

else return false

0👍

Well,I would create a property in data(), like this:

data() {
 urlHasSetting: false
}

in my created() lifecycle method I would check:

var parts = window.location.href.split("/")
var hasSetting = parts.filter("settings")[0]

if (hasSettings) this.urlHasSetting = true

and you will need to create a computed that return urlHasSetting data.

computed: {
  settingComputed() {
    return this.urlHasSetting
  }
}

and you will be able to use your settingComputed in your v-if

Leave a comment