Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabling warnings about inline value attributes for v-model on select #5112

Closed
oliverpool opened this issue Mar 6, 2017 · 2 comments
Closed

Comments

@oliverpool
Copy link

Vue.js version

2.2.0

Reproduction Link

http://jsfiddle.net/wdgfnn0h/3/

Steps to reproduce

Create a <select v-model="value"> tag with a selected option: <option selected>Value</option>.

What is Expected?

I expect not warning because in my app, I initialize the Vue values with the values extracted from the HTML (to keep a no-js compatibility).
This has been discussed in #4733 and implemented in #4770

What is actually happening?

A warning is shown in the console:

[Vue warn]: Error compiling template:

<div id="app">
<select v-model="first">
<option value="0">option0</option>
<option value="1" selected="">option1</option>
</select>
</div>
  • <select v-model="first">:
    inline selected attributes on will be ignored when using v-model. Declare initial values in the component's data option instead.
@ccforward
Copy link

If you want the second option to be selected default, I suggest you remove the selected attribute nad set your data to be

data: {
  first: "1"
}

operate data not DOM

@oliverpool
Copy link
Author

I want my form to still display fine if JS is disabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants