How to render the list in vue.js?
I'm trying to render the list with vue.js. The data has come from api call.
List rendering is ok, until I try to add data-feature_id="@{{searched_feature.id}}"
in li
tag.
When I add it, I got an error:
[Vue warn]: Error compiling template:......
<div class="search_feature_select">
<ul>
<li v-for="searched_feature in searched_features" data-feature_id="@{{searched_feature.id}}" @click="add_to_features_list">
@{{searched_feature.name}}
</li>
</ul>
</div>
How can I put searched_feature.id
in data-feature_id
attribute?
javascript vue.js
add a comment |
I'm trying to render the list with vue.js. The data has come from api call.
List rendering is ok, until I try to add data-feature_id="@{{searched_feature.id}}"
in li
tag.
When I add it, I got an error:
[Vue warn]: Error compiling template:......
<div class="search_feature_select">
<ul>
<li v-for="searched_feature in searched_features" data-feature_id="@{{searched_feature.id}}" @click="add_to_features_list">
@{{searched_feature.name}}
</li>
</ul>
</div>
How can I put searched_feature.id
in data-feature_id
attribute?
javascript vue.js
add a comment |
I'm trying to render the list with vue.js. The data has come from api call.
List rendering is ok, until I try to add data-feature_id="@{{searched_feature.id}}"
in li
tag.
When I add it, I got an error:
[Vue warn]: Error compiling template:......
<div class="search_feature_select">
<ul>
<li v-for="searched_feature in searched_features" data-feature_id="@{{searched_feature.id}}" @click="add_to_features_list">
@{{searched_feature.name}}
</li>
</ul>
</div>
How can I put searched_feature.id
in data-feature_id
attribute?
javascript vue.js
I'm trying to render the list with vue.js. The data has come from api call.
List rendering is ok, until I try to add data-feature_id="@{{searched_feature.id}}"
in li
tag.
When I add it, I got an error:
[Vue warn]: Error compiling template:......
<div class="search_feature_select">
<ul>
<li v-for="searched_feature in searched_features" data-feature_id="@{{searched_feature.id}}" @click="add_to_features_list">
@{{searched_feature.name}}
</li>
</ul>
</div>
How can I put searched_feature.id
in data-feature_id
attribute?
javascript vue.js
javascript vue.js
edited Dec 28 '18 at 10:39
Styx
3,27642334
3,27642334
asked Dec 28 '18 at 9:32
Mg Mg TintMg Mg Tint
112
112
add a comment |
add a comment |
4 Answers
4
active
oldest
votes
You need to add : before the attribute
<div class="search_feature_select">
<ul>
<li v-for="searched_feature in searched_features" :data-feature_id="searched_feature.id" @click="add_to_features_list">
{{searched_feature.name}}
</li>
</ul>
</div>
add a comment |
Add 'v-bind:' prefix of shorthand ':' before attribute to bind dynamic data.
<div class="search_feature_select">
<ul>
<li v-for="searched_feature in searched_features"
:data-feature_id="searched_feature.id"
@click="add_to_features_list">
{{searched_feature.name}}
</li>
</ul>
</div>
See more https://vuejs.org/v2/api/#v-bind
add a comment |
https://vuejs.org/v2/guide/list.html coughcough*
var app = new Vue({
el: "#app",
data: {
searched_features: [
{
id: 1,
name: "One"
},
{
id: 2,
name: "Two"
},
{
id: 3,
name: "Three"
}
]
},
methods: {
add_to_features_list(){}
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<div class="search_feature_select">
<ul>
<li v-for="searched_feature in searched_features" :data-feature_id="searched_feature.id" @click="add_to_features_list">
@{{ searched_feature.name }}
</li>
</ul>
</div>
</div>
add a comment |
if you wish to add the '@' in front of the data-feature_id attribute:
<div class="search_feature_select">
<ul>
<li v-for="searched_feature in searched_features" :data-feature_id="'@' + searched_feature.id" @click="add_to_features_list">
{{searched_feature.name}}
</li>
</ul>
</div>
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53956330%2fhow-to-render-the-list-in-vue-js%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to add : before the attribute
<div class="search_feature_select">
<ul>
<li v-for="searched_feature in searched_features" :data-feature_id="searched_feature.id" @click="add_to_features_list">
{{searched_feature.name}}
</li>
</ul>
</div>
add a comment |
You need to add : before the attribute
<div class="search_feature_select">
<ul>
<li v-for="searched_feature in searched_features" :data-feature_id="searched_feature.id" @click="add_to_features_list">
{{searched_feature.name}}
</li>
</ul>
</div>
add a comment |
You need to add : before the attribute
<div class="search_feature_select">
<ul>
<li v-for="searched_feature in searched_features" :data-feature_id="searched_feature.id" @click="add_to_features_list">
{{searched_feature.name}}
</li>
</ul>
</div>
You need to add : before the attribute
<div class="search_feature_select">
<ul>
<li v-for="searched_feature in searched_features" :data-feature_id="searched_feature.id" @click="add_to_features_list">
{{searched_feature.name}}
</li>
</ul>
</div>
edited Dec 28 '18 at 9:53
answered Dec 28 '18 at 9:41
MahmoudMahmoud
608717
608717
add a comment |
add a comment |
Add 'v-bind:' prefix of shorthand ':' before attribute to bind dynamic data.
<div class="search_feature_select">
<ul>
<li v-for="searched_feature in searched_features"
:data-feature_id="searched_feature.id"
@click="add_to_features_list">
{{searched_feature.name}}
</li>
</ul>
</div>
See more https://vuejs.org/v2/api/#v-bind
add a comment |
Add 'v-bind:' prefix of shorthand ':' before attribute to bind dynamic data.
<div class="search_feature_select">
<ul>
<li v-for="searched_feature in searched_features"
:data-feature_id="searched_feature.id"
@click="add_to_features_list">
{{searched_feature.name}}
</li>
</ul>
</div>
See more https://vuejs.org/v2/api/#v-bind
add a comment |
Add 'v-bind:' prefix of shorthand ':' before attribute to bind dynamic data.
<div class="search_feature_select">
<ul>
<li v-for="searched_feature in searched_features"
:data-feature_id="searched_feature.id"
@click="add_to_features_list">
{{searched_feature.name}}
</li>
</ul>
</div>
See more https://vuejs.org/v2/api/#v-bind
Add 'v-bind:' prefix of shorthand ':' before attribute to bind dynamic data.
<div class="search_feature_select">
<ul>
<li v-for="searched_feature in searched_features"
:data-feature_id="searched_feature.id"
@click="add_to_features_list">
{{searched_feature.name}}
</li>
</ul>
</div>
See more https://vuejs.org/v2/api/#v-bind
answered Dec 28 '18 at 9:52
Cong NguyenCong Nguyen
35728
35728
add a comment |
add a comment |
https://vuejs.org/v2/guide/list.html coughcough*
var app = new Vue({
el: "#app",
data: {
searched_features: [
{
id: 1,
name: "One"
},
{
id: 2,
name: "Two"
},
{
id: 3,
name: "Three"
}
]
},
methods: {
add_to_features_list(){}
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<div class="search_feature_select">
<ul>
<li v-for="searched_feature in searched_features" :data-feature_id="searched_feature.id" @click="add_to_features_list">
@{{ searched_feature.name }}
</li>
</ul>
</div>
</div>
add a comment |
https://vuejs.org/v2/guide/list.html coughcough*
var app = new Vue({
el: "#app",
data: {
searched_features: [
{
id: 1,
name: "One"
},
{
id: 2,
name: "Two"
},
{
id: 3,
name: "Three"
}
]
},
methods: {
add_to_features_list(){}
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<div class="search_feature_select">
<ul>
<li v-for="searched_feature in searched_features" :data-feature_id="searched_feature.id" @click="add_to_features_list">
@{{ searched_feature.name }}
</li>
</ul>
</div>
</div>
add a comment |
https://vuejs.org/v2/guide/list.html coughcough*
var app = new Vue({
el: "#app",
data: {
searched_features: [
{
id: 1,
name: "One"
},
{
id: 2,
name: "Two"
},
{
id: 3,
name: "Three"
}
]
},
methods: {
add_to_features_list(){}
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<div class="search_feature_select">
<ul>
<li v-for="searched_feature in searched_features" :data-feature_id="searched_feature.id" @click="add_to_features_list">
@{{ searched_feature.name }}
</li>
</ul>
</div>
</div>
https://vuejs.org/v2/guide/list.html coughcough*
var app = new Vue({
el: "#app",
data: {
searched_features: [
{
id: 1,
name: "One"
},
{
id: 2,
name: "Two"
},
{
id: 3,
name: "Three"
}
]
},
methods: {
add_to_features_list(){}
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<div class="search_feature_select">
<ul>
<li v-for="searched_feature in searched_features" :data-feature_id="searched_feature.id" @click="add_to_features_list">
@{{ searched_feature.name }}
</li>
</ul>
</div>
</div>
var app = new Vue({
el: "#app",
data: {
searched_features: [
{
id: 1,
name: "One"
},
{
id: 2,
name: "Two"
},
{
id: 3,
name: "Three"
}
]
},
methods: {
add_to_features_list(){}
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<div class="search_feature_select">
<ul>
<li v-for="searched_feature in searched_features" :data-feature_id="searched_feature.id" @click="add_to_features_list">
@{{ searched_feature.name }}
</li>
</ul>
</div>
</div>
var app = new Vue({
el: "#app",
data: {
searched_features: [
{
id: 1,
name: "One"
},
{
id: 2,
name: "Two"
},
{
id: 3,
name: "Three"
}
]
},
methods: {
add_to_features_list(){}
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<div class="search_feature_select">
<ul>
<li v-for="searched_feature in searched_features" :data-feature_id="searched_feature.id" @click="add_to_features_list">
@{{ searched_feature.name }}
</li>
</ul>
</div>
</div>
answered Dec 28 '18 at 9:53
AnugaAnuga
926718
926718
add a comment |
add a comment |
if you wish to add the '@' in front of the data-feature_id attribute:
<div class="search_feature_select">
<ul>
<li v-for="searched_feature in searched_features" :data-feature_id="'@' + searched_feature.id" @click="add_to_features_list">
{{searched_feature.name}}
</li>
</ul>
</div>
add a comment |
if you wish to add the '@' in front of the data-feature_id attribute:
<div class="search_feature_select">
<ul>
<li v-for="searched_feature in searched_features" :data-feature_id="'@' + searched_feature.id" @click="add_to_features_list">
{{searched_feature.name}}
</li>
</ul>
</div>
add a comment |
if you wish to add the '@' in front of the data-feature_id attribute:
<div class="search_feature_select">
<ul>
<li v-for="searched_feature in searched_features" :data-feature_id="'@' + searched_feature.id" @click="add_to_features_list">
{{searched_feature.name}}
</li>
</ul>
</div>
if you wish to add the '@' in front of the data-feature_id attribute:
<div class="search_feature_select">
<ul>
<li v-for="searched_feature in searched_features" :data-feature_id="'@' + searched_feature.id" @click="add_to_features_list">
{{searched_feature.name}}
</li>
</ul>
</div>
answered Dec 28 '18 at 9:56
Tang YunTang Yun
898
898
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53956330%2fhow-to-render-the-list-in-vue-js%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown