会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132553个问题

<template>
    <div>
        <button @cilck="showA">A组件</button>
        <button @click="showB">B组件</button>
        <button @click="showC">kong组件</button>
        <keep-alive>
            <component :is="current"></component>
        </keep-alive>
        

        动态组件    
    </div>
</template>

<script>
import AComponent from "./child/AComponent";
import BComponent from "./child/BComponent";
export default {
    name:"dongtai_components",
    data(){
        return{
            current:AComponent,

        }
    },
    components:{
        AComponent,
        BComponent,
    },methods:{
        showA(){
            this.current=AComponent;
        },
        showB(){
            this.current=BComponent;
        },showC(){
            this.current=AComponent;
        }


    }
}
</script>
<template>
    <div>
        AComponentaaa
    </div>
</template>
<script>
export default {
    name:"AComponent",
    data(){
        return{

        }
    }
}
</script>
<template>
    <div>
        BComponent
        {{msg}}
        <button @click="handle">改变数据</button>
        
    </div>
</template>
<script>
export default {
    name:"BComponent",
    data(){
        return{
            msg:"原有数据"

        }
    },
    methods:{
        handle(){
            this.msg="这是修改后的数据"

        }
    }
}
</script>

老师我这个showA点击之后没效果,而且把整个showA删除之后,后面两个事件也没效果了。是怎么回事

WEB前端全系列/第十九阶段:Vue2知识体系(旧)/Vue基础知识 23626楼
JAVA 全系列/第二十阶段:租房网(Spring Cloud最新架构)/Livegoods第一天 23627楼

#coding=utf-8
# 通过grid布局-实现计算器软件界面

from tkinter import *
from tkinter import messagebox
import random

class Application(Frame):

    def __init__(self,master=None):
        super().__init__(master)
        self.master = master
        self.pack()
        self.createWidget

    def createWidget(self):
        """通过grid布局实现计算器界面"""
        btnText = (("MC","M+","M-","MR"),
                   ("C","±","➗","✖"),
                   (7,8,9,"-"),
                   (4,5,6,"+"),
                   (1,2,3,"="),
                   (0,"."))

        Entry(self).grid(row=0,column=0,columnspan=4,pady=10)

        for rindex,r in enumerate(btnText):
            for cindex,c in enumerate(r):
                if c == "=":
                    Button(self, text=c, width=2).grid(row=rindex+1, column=cindex, rowspan=2,sticky=NSEW)
                elif c == 0:
                    Button(self, text=c, width=2).grid(row=rindex+1, column=cindex,columnspan=2, sticky=NSEW)
                elif c == ".":
                    Button(self, text=c, width=2).grid(row=rindex+1, column=cindex+1, sticky=NSEW)
                else:
                    Button(self,text=c,width=2).grid(row=rindex+1,column=cindex,sticky=NSEW)




if __name__ == '__main__':
    root = Tk()
    root.geometry("200x200+200+300")
    app = Application(master=root)
    root.mainloop()

image.png

老师,为啥我这出来是这个样子,怎么没有计算器的内容啊,错哪了

Python 全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 23629楼
JAVA 全系列/第二十九阶段:数据结构和算法BATJ大厂面试重难点/字符串和矩阵 23630楼
JAVA 全系列/第四阶段:网页编程和设计/Javascript 语言(旧) 23631楼
JAVA 全系列/第十八阶段:亿级高并发电商项目_架构/编码(旧)/电商:使用Solr实现数据搜索 23632楼

from fake_useragent import UserAgent
import requests
from lxml import etree
from time import sleep

def get_html(url):
    #传递要爬取的地址
    #返回html
    headers= {"User-Agent":UserAgent().chrome}
    resp = requests.get(url,headers=headers)
    sleep(2)
    if resp.status_code == 200:
        return resp.text
    else:
        return None

def parse_list(html):
    #传递进来一个有电影列表的html
    #返回一个电影列表的url
    e = etree.HTML(html)
    list_url = ['https://maoyan.com/{}'.format(url) for url in e.xpath('//div[@class="movie-item-hover"]/a/@href')]
    return list_url

def pares_index(html):
    #传递进来一个有电影信息的html
    #返回已提取好的电影信息
    e = etree.HTML(html)
    name = e.xpath('//h1[@class="name"]/text()')
    type = e.xpath('//li[@class="ellipsis"]/a[1]/text()')
    actors = e.xpath('//li[@class="celebrity actor"]/div[@class="info"]/a/text()')
    actors = format_data(actors)
    return {"name":name,"type":type,"actors":actors}

#去重
def format_data(actors):
    actor_set = set()
    for actor in actors:
        actor_set.add(actor.strip())
    return actor_set

def main():
    num = int(input("请输入要获取多少页:"))
    for page in range(num):
        url = 'https://maoyan.com/films?showType=3&offset={}'.format(page*30)
        list_html = get_html(url)
        list_url = parse_list(list_html)
        for url in list_url:
            info_html = get_html(url)
            movie = pares_index(info_html)
            print(movie)

if __name__ == '__main__':
    main()

image.png

老师,我运行后出现如上报错,然后我尝试修改了一下代码如下。

image.png

但是执行后出来的效果如下图,求帮助。

image.png

Python 全系列/第十五阶段:Python 爬虫开发/爬虫反反爬- 23633楼

.content{
    width: 100%;
    overflow: hidden;
    padding: 4px 0 12px;
}
.title{
    text-align: left;
    color: #333;
    font-size: 22px;
    font-weight: 200;
    line-height: 58px;
}
.phone-box{
    width: 100%;
    height: 614px;
}
.yang-left{
    width: 234px;
    height: 100%;
    background-color: #ff6700;
    float: left;
}
.yang-right{
    width: 992px;
    height: 614px;
    float: left;
}
.yang-left img{
    width: 234px;
    height: 614px;
}
.items1{
    width: 234px;
    height: 300px;
    background-color: #e0e0e0;
    padding: 20px 0;
    margin: 0 0 14px 14px;
    float: left;
    transition: all .2s linear;
    box-sizing: border-box;
}
.img1{
    width: 164px;
    margin-bottom: 18px;
}
.items1:hover{
    transform: translateY(-2px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, .1);
}
.name1{
    width: 214px;
    height: 20.8;
    color: #333;
    font-size: 14px;
    line-height: 21px;
    margin: 0 auto 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.name2{
    width: 214px;
    height: 18px;
    color: #b0b0b0;
    font-size: 12px;
    line-height: 18px;
    margin: 0 10px 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.name3{
    width: 214px;
    height: 20.8px;
    color: #ff6700;
    font-size: 14px;
    line-height: 18px;
    margin: 0 10px 14px;
}
.big-img{
    width: 1226px;
    height: 120px;
    margin: 22px 0;
}
老师,line-height: 21px这个不加可以吗?white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsi这行代码有啥用?

WEB前端全系列/第一阶段:HTML5+CSS3模块/CSS3新特性 23634楼
Python 全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 23635楼
JAVA 全系列/第六阶段:项目管理与SSM框架/SpringMVC 23636楼
Python 全系列/第十五阶段:Python 爬虫开发/爬虫基础(旧) 23638楼
Python 全系列/第十五阶段:Python 爬虫开发/爬虫基础(旧) 23639楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637