2👍
You can combine the optional chaining operator with the nullish coalescing operator like this :
<v-card-subtitle class="py-0 my-0">{{ vc_rule?.url ?? 'empty' }}</v-card-subtitle>
1👍
Try with Logical_OR -> ||
new Vue({
el: '#app',
vuetify: new Vuetify(),
data() {
return {
vc_rule: null
}
}
})
<link href="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.min.css" rel="stylesheet">
<div id="app">
<v-app>
<v-card>
<v-card-subtitle class="py-0 my-0">{{ vc_rule?.url || 'empty' }}</v-card-subtitle>
</v-card>
</v-app>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2.x/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.js"></script>
- [Vuejs]-Changing props from child in parent Vuejs
- [Vuejs]-Vue.js–vue cli3 changing favicon not working
1👍
If I understand your requirement correctly, we can achieve that in the HTML template itself via use of Optional chaining (?.) along with Nullish coalescing operator (??).
Working Demo :
new Vue({
el: '#app',
vuetify: new Vuetify(),
data() {
return {
vc_rule: null
}
}
})
<script src="https://cdn.jsdelivr.net/npm/vue@2.x/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.js"></script>
<link href="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.min.css" rel="stylesheet">
<div id="app">
<v-card-subtitle class="py-0 my-0">{{ vc_rule?.url ?? 'empty' }}</v-card-subtitle>
</div>
- [Vuejs]-What is the best practice to develop the cross-platform components with Vue.js 2.0?
- [Vuejs]-CSS – How to properly use flex-basis?
Source:stackexchange.com