Comments (2)
Use v-model
directive directly.
Some code for example below
<v-suggest
show-field="name"
v-model="userName"
:data="list"
>
</v-suggest>
<script>
export default {
data () {
return {
list: [
{ name: 'tom' },
{ name: 'jerry' },
]
userName = 'jerry'
}
}
}
</script>
from v-suggest.
Dear Terry,
Thanks for the answer, but what will be the proper solution if we need to set "row", not only "text". For example at the moment I use wrapper component which holds v-suggest. I use props to set list items and current object:
The list contains data in simmilar format:
// List object is similar to:
{
id: 1, name: "test1",
id: 2, name: "test2",
id: 3, name: "test3",
id: 4, name: "test4",
...
...
...
}
Then in wrapper component I use some parameters like:
ref="suggested" :key-field="keyField" :data="list" @values="values" @clear="$emit('clear')" :show-field="showField":full-list="true" etc.
and than use something like this:
<script>
export default {
props: {
list: { type: [Object, Array], required: true },
current: { type: [Object, Array], required: true },
v: { type: String, default: '' },
t: { type: String, default: '' },
},
data() {
return {
keyField: 'id',
};
},
mounted: function() {
this.$nextTick(() => {
this.$refs.suggested.text = this.current[this.t] ? this.current[this.t] : '';
});
},
methods: {
values(row) {
this.$emit('values', row);
},
clearText() {
console.log('Cleared from BranchNew "clear" method!');
},
showField(row) {
return row.Name;
},
},
It works, but I want to check if there is better way to do this!
Thanks in advance
from v-suggest.
Related Issues (19)
- Selected should return entire item vs just text HOT 4
- 支持根据输入的关键字动态获取吗? HOT 3
- how can I make dropdown to be open by just clicking in the input HOT 11
- Please publish d.ts as @types/v-suggest node module
- Emit "Clear" event - when user clicks on "Clear" button HOT 3
- New data doesn't rerender when already focused. Bug with async data.
- How to add class from css framework? HOT 4
- On local machine is run well but go to server is not working(don't show input control) HOT 1
- Add a proper way to set "error" class to <input> element inside <v-suggest>
- When v-model has assigned value, suggestion dropdown wont show up. HOT 1
- Cannot put a space in the typed text HOT 1
- Vue 3
- Placeholder option HOT 1
- Invalid build for v-suggest.js HOT 1
- I'm trying to add attribute such as disabled but its not working. HOT 2
- mutil select item? HOT 1
- Uncaught TypeError: Cannot read property 'toLowerCase' of undefined HOT 2
- It is possible to delay the transfer after pressing enter. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from v-suggest.