Home > Web Front-end > Vue.js > How to render vue.js images

How to render vue.js images

coldplay.xixi
Release: 2020-11-17 15:32:21
Original
3504 people have browsed it

Vue.js method of rendering images: first initialize the list; then obtain the parameters brought from the previous page, obtain api, app, foot; then pass the parameters backward; and finally render the local image.

How to render vue.js images

[Related article recommendations: vue.js]

vue.js rendering image Method:

Passing values ​​with parameters

local food

<template>
    <div>
        <h1>美食</h1>
        <table border="1">
            <tr>
                <td>美食</td>
                <td>美食图片</td>
                <td>美食价格</td>
            </tr>
            <tr  v-for="i in footlist">
                <td>{{i.name}}</td>
                <td><img :src="i.img" height="100" width="100"></td> // 渲染本地图片
                <td>{{i.price}}</td>
            </tr>
        </table>
    </div>
</template>
<script>
    export default {
        name: "foot",
        data: function () {
            return {
                footlist: []  //初始化列表
            }
        },
        mounted() {
            var aa = this.$route.params.id;  //获取上个页面带过来的参数
            this.axios({
            url: &#39;/api/app/foot/&#39;,  //api 是跨越时设置的 app是路由分发 foot是后端的接口
            data: {aa:aa},   //向后端传递参数
            method: &#39;post&#39;  //post方式
        }).then((res) => {
            if (res.data.code == 200) {  // code == 200时
                this.footlist = res.data.message; // 初始化赋值
                console.log(res)
            }
        })
        }
    }
</script>
<style scoped>
</style>
Copy after login

Related free learning recommendations: javascript(Video)

The above is the detailed content of How to render vue.js images. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template