我尝试从我的API服务器获取数据,axios但我收到此错误:
'v-bind' directives require an attribute value.
Run Code Online (Sandbox Code Playgroud)
我不知道我必须用v-bind它来解决它.这是我的代码:
<template>
<div class="main">
<p class="title"><span>Fetured Items</span><br>
<span>Shop for items based on what we featured in this week</span></p>
<div v-if="products && products.length" class="content">
<content-item v-for="product in products" :key="product.id"
v-bind:name="product.name"
v-bind:price="product.price"
v-bind:srcToProdImage= 'localhost:8081/' + product.productImage></content-item>
</div>
<p class="cont-btn">
<button class="btn">Browse All Product <span><i class="fas fa-arrow-right"></i></span></button>
</p>
</div>
</template>
<script>
import Content_item from './Content-item';
import axios from 'axios';
export default {
data:{
products,
errors
},
created(){
axios.get('localhost:8081/products')
.then((result) => {
this.products …Run Code Online (Sandbox Code Playgroud)