Closed cbalbin closed 1 year ago
Vue.js 3.x introduced some significant changes, one of which is the working method of the v-model
directive.
In Vue.js 2.x, v-model
was used to implement two-way data binding between parent and child components. You could use v-model
on any custom components, and this would automatically translate into a value
prop and an input
event. However, this design seemed too rigid in some use cases.
Therefore, in Vue.js 3.x, components using v-model
need to explicitly define receiving a modelValue
prop and emitting an update:modelValue
event. This means that you can run custom operations when the model value updates. But inversely, this also implies that you can no longer just use v-model
on root instances as in Vue 2.x.
see https://v3-migration.vuejs.org/breaking-changes/v-model.html
<p>Message is: {{ message }}</p>
<custom-input v-model="message"></custom-input>
window.$docsify = {
vueComponents: {
'custom-input': {
props: ['modelValue'],
emits: ['update:modelValue'],
template: `
<input
type="text"
:value="modelValue"
@input="$emit('update:modelValue', $event.target.value)"
/>
`
}
}
};
I think we can close this because this is a difference in Vue 3 API from Vue 2, not a difference in Docsify. Please re-open if I missed something.
Bug Report
Steps to reproduce
Created reproducible sandbox below
Create starter project
Add Vue 3 and a global Vue var in VueGlobalOptions. Resulting index.html
Add input with v-model against the message ref defined in vueGlobalOptions to README.md
Start local server
Current behaviour
v-model not functional
Expected behaviour
Expect "Message is:" to update with input
Other relevant information
Swap Vue 3 script tag in index.html with that for Vue 2 and the problem goes away.
[X] Bug still occurs when all/other plugins are disabled?
Docsify plugins (if the bug happens when plugins enabled, please try to isolate the issue): None
Please create a reproducible sandbox
Please see reproducible sandbox below
Mention the docsify version in which this bug was not present (if any)
Unkown