Open wtsang11 opened 3 years ago
Code > Preferences > Keyboard Shortcut , select keybinding: Shift+Option+F Or Install formatter extension Prettier and Vetur In the settings of Vetur, make sure Default formatter is prettier
Ref https://012.vuejs.org/guide/directives.html A directive is an instruction to activate a certain action in a DOM element. Example: v-show="message.length" show the element if length is greater than 0.
Note that v-if will not simply hide the DOM element but delete it. v-else works along with v-if.
Example: v-model="message" binds the element to a data element message.
Example: 3 different ways to do the same:
In computed object: errorStyle() { if (this.message.length > 22) { return { color: 'red', background: 'pink', }; } }, In style object: .error { color: red; background: pink; }
Ref https://developer.chrome.com/docs/devtools/css/overrides/ Inspect of the element in question showed Invalid value in: .border-grey { border: 1 px solid grey; }
Solution: Remove the space between 1 px i.e. 1px
It is more efficient to use computed property than calling a method directly because the function is called only when the element in question changes, not whenever the page changes. Example:
Uppercase message: {{ messageUppercase }}
computed: { messageUppercase() { return this.message.toUpperCase(); }, },
A filter is mainly used simply to transform a value of a DOM element. Example:
filters: { messageLowercase(value) { return value.toLowerCase(); }, }, The filter is used by piping a value to it:Lowercase message: {{ message | messageLowercase }}
beforeCreate -> created -> beforeMount -> mounted
beforeUpdate -> updated
beforeDestroy
A reference to a DOM element. It can be accessed by the vue variable $refs. This provide a handy utility to access the element and perform tasks such as input verification.
Example:
<div ref="messageLength">{{ message.length }}</div>
mounted() { if (this.message.length > 22) { this.$refs.messageLength.className = 'error'; } }
http://localhost/TechNotes/wp-admin/post.php?post=1417&action=edit
VSC: http://localhost/lab/python/utilities/study_codes/opencodes.php?f=/Users/wtsang/Lab/vue/danny_vue_cross_platform_apps/
Vue Documentation https://vuejs.org/v2/guide/#Getting-Started