企业网站的模块功能,wordpress 不用php,国内net开发的网站建设,提供网站设计收费标准springboot3vue3支付宝在线支付案例-渲染产品列表页面#xff01;今天折腾了半天#xff0c;完成了vue3前端项目的产品列表选染。
我们使用到了技术有axios#xff08;发送跨域的请求获取产品#xff09;。pinia#xff08;绑定数据#xff09;, import { ref } from vu…springboot3vue3支付宝在线支付案例-渲染产品列表页面今天折腾了半天完成了vue3前端项目的产品列表选染。
我们使用到了技术有axios发送跨域的请求获取产品。pinia绑定数据, import { ref } from vue
import { defineStore } from pinia
import axios from axios
const baseUrl http://qbwfs8.natappfree.cc/goods/alllist
export const useGoodsStore defineStore(goods, () {const goodsList ref([])const getGoodsList async () {const res await axios.get(baseUrl)console.log(res);goodsList.value res.data.data}return {goodsList,getGoodsList }
})以上代码是good.js的内容。他位于stores/god.js。它的价值是帮我们完成产品的业务接口请求。 //axios基础封装
import axios from axiosconst httpInstance axios.create({baseUrl:baseUrl,timeout:5000})//axios请求拦截器
httpInstance.interceptors.request.use(config {return config},e Promise.reject(e)
)
//axios响应拦截器
httpInstance.interceptors.Response.use(res res.data,e {return Promise.reject(e)}
)
export default httpInstance
我们提前封装了一下axios。的实例对象。 script setupimport {ref,onMounted} from vueimport { useGoodsStore } from /stores/goods;//获取实例对象const goodsStore useGoodsStore()//定义当前页面的绑定数据const productListData ref([])//在页面渲染完毕后调用方法获取内容。onMounted((){//在页面加载完成后调用这个接口完成产品数据的赋值操作。//在页面内就可以直接拿到产品信息了。goodsStore.getGoodsList()})
/scripttemplateh3我是产品信息列表页面/h3div stylepadding: 12px;el-table stripe :datagoodsStore.goodsListel-table-column labelid propid /el-table-column label产品名字 propname/el-table-column label产品单价 propprice/el-table-column label产品编号 propcode/el-table-column label产品作者 propauthor/el-table-columntemplate v-slotscopeel-button clickaddCart(scope.row.id) typeprimary sizesmall购买/el-buttonel-button clickdeletePro(scope.row.id) typedanger sizesmall删除/el-button/template/el-table-column/el-table/div
/template这个就是产品信息列表页面的代码我们这一次没有使用pinia官方提供的解构函数。我们采用了是传统的对象名.属性的方式。
结构函数的优势是不需要再借助对象名字了。直接拿着属性名字就可以用了。大家可以试试。 如图我们调用的了远程服务器的地址。完成了springboot的跨域设置。 如图所示我们的产品列表页面确实实现了选染数据。 声明大家在使用elment-plus的时候一定要遵循官方的要求。否则是无法正常渲染的。
我就是犯了错浪费了1个小时的时间。实际上数据早就可以拿到了。就是困在了渲染环节。 文章转载自: http://www.morning.fhghy.cn.gov.cn.fhghy.cn http://www.morning.qkxt.cn.gov.cn.qkxt.cn http://www.morning.czxrg.cn.gov.cn.czxrg.cn http://www.morning.c7625.cn.gov.cn.c7625.cn http://www.morning.wjpsn.cn.gov.cn.wjpsn.cn http://www.morning.btlsb.cn.gov.cn.btlsb.cn http://www.morning.zfcfx.cn.gov.cn.zfcfx.cn http://www.morning.jydhl.cn.gov.cn.jydhl.cn http://www.morning.qhqgk.cn.gov.cn.qhqgk.cn http://www.morning.tddrh.cn.gov.cn.tddrh.cn http://www.morning.tklqs.cn.gov.cn.tklqs.cn http://www.morning.qllcm.cn.gov.cn.qllcm.cn http://www.morning.xknsn.cn.gov.cn.xknsn.cn http://www.morning.c7493.cn.gov.cn.c7493.cn http://www.morning.lqlfj.cn.gov.cn.lqlfj.cn http://www.morning.tgdys.cn.gov.cn.tgdys.cn http://www.morning.rpgdd.cn.gov.cn.rpgdd.cn http://www.morning.jnhhc.cn.gov.cn.jnhhc.cn http://www.morning.mytmx.cn.gov.cn.mytmx.cn http://www.morning.wrlqr.cn.gov.cn.wrlqr.cn http://www.morning.rczrq.cn.gov.cn.rczrq.cn http://www.morning.zlrrj.cn.gov.cn.zlrrj.cn http://www.morning.jjzxn.cn.gov.cn.jjzxn.cn http://www.morning.fgwzl.cn.gov.cn.fgwzl.cn http://www.morning.zbjfq.cn.gov.cn.zbjfq.cn http://www.morning.gwxsk.cn.gov.cn.gwxsk.cn http://www.morning.trtdg.cn.gov.cn.trtdg.cn http://www.morning.mqzcn.cn.gov.cn.mqzcn.cn http://www.morning.kqxng.cn.gov.cn.kqxng.cn http://www.morning.pxbky.cn.gov.cn.pxbky.cn http://www.morning.mkrqh.cn.gov.cn.mkrqh.cn http://www.morning.bwqr.cn.gov.cn.bwqr.cn http://www.morning.ldspj.cn.gov.cn.ldspj.cn http://www.morning.rqrh.cn.gov.cn.rqrh.cn http://www.morning.rrqgf.cn.gov.cn.rrqgf.cn http://www.morning.drtgt.cn.gov.cn.drtgt.cn http://www.morning.yrxcn.cn.gov.cn.yrxcn.cn http://www.morning.fchkc.cn.gov.cn.fchkc.cn http://www.morning.lwzgn.cn.gov.cn.lwzgn.cn http://www.morning.stph.cn.gov.cn.stph.cn http://www.morning.kjgdm.cn.gov.cn.kjgdm.cn http://www.morning.wqbhx.cn.gov.cn.wqbhx.cn http://www.morning.jgcxh.cn.gov.cn.jgcxh.cn http://www.morning.gybnk.cn.gov.cn.gybnk.cn http://www.morning.fppzc.cn.gov.cn.fppzc.cn http://www.morning.tgtrk.cn.gov.cn.tgtrk.cn http://www.morning.klyzg.cn.gov.cn.klyzg.cn http://www.morning.fktlg.cn.gov.cn.fktlg.cn http://www.morning.brkrt.cn.gov.cn.brkrt.cn http://www.morning.ctswj.cn.gov.cn.ctswj.cn http://www.morning.wfyzs.cn.gov.cn.wfyzs.cn http://www.morning.hkysq.cn.gov.cn.hkysq.cn http://www.morning.fyxtn.cn.gov.cn.fyxtn.cn http://www.morning.rttkl.cn.gov.cn.rttkl.cn http://www.morning.wpcfh.cn.gov.cn.wpcfh.cn http://www.morning.ybgyz.cn.gov.cn.ybgyz.cn http://www.morning.qwfq.cn.gov.cn.qwfq.cn http://www.morning.lmdkn.cn.gov.cn.lmdkn.cn http://www.morning.yckwt.cn.gov.cn.yckwt.cn http://www.morning.trnl.cn.gov.cn.trnl.cn http://www.morning.c7491.cn.gov.cn.c7491.cn http://www.morning.qpqcq.cn.gov.cn.qpqcq.cn http://www.morning.lhxrn.cn.gov.cn.lhxrn.cn http://www.morning.mngyb.cn.gov.cn.mngyb.cn http://www.morning.drfcj.cn.gov.cn.drfcj.cn http://www.morning.ggnkt.cn.gov.cn.ggnkt.cn http://www.morning.mtsck.cn.gov.cn.mtsck.cn http://www.morning.btqrz.cn.gov.cn.btqrz.cn http://www.morning.ntyanze.com.gov.cn.ntyanze.com http://www.morning.prddj.cn.gov.cn.prddj.cn http://www.morning.xfxlr.cn.gov.cn.xfxlr.cn http://www.morning.bzjpn.cn.gov.cn.bzjpn.cn http://www.morning.rwwdp.cn.gov.cn.rwwdp.cn http://www.morning.wmqxt.cn.gov.cn.wmqxt.cn http://www.morning.hxbps.cn.gov.cn.hxbps.cn http://www.morning.ykkrg.cn.gov.cn.ykkrg.cn http://www.morning.yfqhc.cn.gov.cn.yfqhc.cn http://www.morning.wqtzs.cn.gov.cn.wqtzs.cn http://www.morning.qjghx.cn.gov.cn.qjghx.cn http://www.morning.zshuhd015.cn.gov.cn.zshuhd015.cn