question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Assign only value

See original GitHub issue

Hi, i want assign only the value to a model:

options = [
{value: 'a', label: 'A'}
]

<v-select 
            :value.sync="selected" 
            :options="options">             
        </v-select>

When i select an option, selected is:

selected: {value: 'a', label: 'A'};

I want only this:

selected: 'a';

Whats the problem here or whats the solution?

Thanks!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
sagalbotcommented, Oct 31, 2016

@NightZpy, as you’ve seen vue-select returns the entire object by default, and @gallib solution will work, but you probably need to drop .sync as well:

<v-select :value="selected" :on-change="onChange" :options="options"></v-select>

//  in the VM
onChange(obj) {
   this.selected = obj.value;
}

Sorry for the slow reply, hope you got this sorted out.

1reaction
gallibcommented, Oct 28, 2016

Hi,

I had the same problem.

I used the on-change event to resolve it.

my function looks like:

onChange(obj) {
    this.selected = obj.value;
}

Hope that can help you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Object.assign() - JavaScript - MDN Web Docs
The Object.assign() method only copies enumerable and own properties from a source object to a target object. It uses [[Get]] on the source...
Read more >
javascript - Object.assign, values only
I can write a method which does, but I wanted to see if there was already a solution to this problem first.
Read more >
Assign other value to a variable from two possible values
Suppose a variable x can have only two possible values a and b, and you wish to assign to x the value other...
Read more >
Assign-once Variables
By saying that Prolog has assign-once variables, I mean that any particular variable in a Prolog procedure can only ever get one value...
Read more >
= (assign) / Reference / Processing.org
Assigns a value to a variable. The "=" sign does not mean "equals", but is used to place data within a variable. The...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found