मुझे अपने व्यू घटकों में डेटा प्रदर्शित करने में परेशानी हो रही है। मैं Vueify का उपयोग कर रहा हूं और मैं listings.vue
घटक से लिस्टिंग की एक सरणी लोड करने की कोशिश कर रहा हूं और मुझे त्रुटियां मिल रही हैं। साथ ही, मुझे समझ में नहीं आता कि computed
विधि के माध्यम से डेटा को कैसे खींचें। किसी भी सहायता की सराहना की जाएगी।मैं Vue.js (Vueify का उपयोग करके) के साथ घटकों के माध्यम से डेटा कैसे प्रदर्शित करूं?
यह त्रुटि मैं कंसोल में हो रही है:
[Vue warn]: The "data" option should be a function that returns a per-instance value in component definitions.
[Vue warn]: $mount() should be called only once.
यहाँ मेरी app.vue
// app.vue
<style>
.red {
color: #f00;
}
</style>
<template>
<div class="container">
<div class="listings" v-component="listings" v-repeat="listing"></div>
</div>
</template>
<script>
module.exports = {
replace: true,
el: '#app',
components: {
'listings': require('./components/listings.vue')
}
}
</script>
यहाँ मेरी listings.vue घटक है
<style>
.red {
color: #f00;
}
</style>
<template>
<div class="listing">{{title}} <br> {{description}}</div>
</template>
<script>
module.exports = {
data: {
listing: [
{
title: 'Listing title number one',
description: 'Description 1'
},
{
title: 'Listing title number two',
description: 'Description 2'
}
]
},
// computed: {
// get: function() {
// var request = require('superagent');
// request
// .get('/post')
// .end(function (res) {
// // Return this to the data object above
// // return res.title + res.description (for each one)
// });
// }
// }
}
</script>
वह @Evan आप क्यों है? दस्तावेज़ों में भी वही बात है [https://vuejs.org/v2/guide/components.html#data-Must-Be-a- समारोह) – peter
फ़ंक्शन में डेटा को लपेटना क्यों है और प्रोप डॉन ' टी है? –