Home > Web Front-end > JS Tutorial > body text

Code example of using render function to generate picture pop-up window

不言
Release: 2019-04-02 11:04:50
forward
2804 people have browsed it

The content of this article is about the code example of the render function to generate a picture pop-up window. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

The list of thumbnails in the project is displayed, and we decided to make a double-click picture pop-up window effect. The project uses the iview UI framework and uses the Modal component. The following is the original code of the picture pop-up box generated by the render function. The double-click action calls the showLargeImage method. The following is the original code of the double-click action

            showLargeImage(item){
                console.log(111);
                if(!item.img_url){
                    this.$Message('未获取到图片!');
                    return;
                }
                this.$Modal.confirm({
                    width:444,
                    render: (h) => {
                        return h('img', {
                            'class':'render_img',
                            attrs: {
                                src: this.api.baseURL+item.img_url,
                                width:400,
                            },
                        })
                    }
                })
            },
Copy after login

The parameter h of the first arrow function in render is the createElement method, and the first string parameter img of createElement is the label.

The second parameter is an object that defines the class of the image. src in attrs is the image path. width defines the width of the image display. This width value can be adjusted according to the Modal width.

【Related recommendations: JavaScript video tutorial

The above is the detailed content of Code example of using render function to generate picture pop-up window. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!