vue 问题总结

  • 1、 动态设置图片,
<img :src="url">

data() {
    return {
        url: require(相对路径) // 直接写相对路径会出错
    }
}
  • 2、props 传递

子组件中

    <div>{{dataName}}</div>
    //==
    props: ['name'],
    name: 'child',
    data() {
        return {dataName: this.name}
    }

父组件


<child name="test" />
// -
import child from '';
component: [
    child
]

猜你喜欢

转载自www.cnblogs.com/Running00/p/11639302.html