飞墨悬云
飞墨悬云
  • 发布:2020-01-17 12:18
  • 更新:2020-07-09 17:53
  • 阅读:2894

uniapp运行到小程序props传值有问题

分类:uni-app

在小程序下原型上的值无法以props传递,且在html中也无法拿到

<template>  
    <view class="content">  
        <view class="text-area">  
            <text class="title">{{title}}</text>  
        </view>  
        <myCom :zhang='zhang'></myCom>  
    </view>  
</template>  

<script>  
    import myCom from '../../component/myComponent.vue'  
    import Person from './data.js'  
    export default {  
        components:{  
            myCom  
        },  
        data() {  
            return {  
                title: 'Hello',  
                zhang:''  
            }  
        },  
        onLoad() {  
            this.zhang = new Person('张三',23);  
            console.log(this.zhang)  
        },  
        methods: {  

        }  
    }  
</script>  
<style>   
.content {  
        display: flex;  
        flex-direction: column;  
        align-items: center;  
        justify-content: center;  
    }  

    .logo {  
        height: 200rpx;  
        width: 200rpx;  
        margin-top: 200rpx;  
        margin-left: auto;  
        margin-right: auto;  
        margin-bottom: 50rpx;  
    }  

    .text-area {  
        display: flex;  
        justify-content: center;  
    }  

    .title {  
        font-size: 36rpx;  
        color: #8f8f94;  
    }  
</style>  
<template>  
    <view class="fatherCom">  
        这是MYCOM--{{nm?nm:'如果显示此行,则html中也无法获取到原型'}}  
        <nestedCom :nm='nm'></nestedCom>  
    </view>  
</template>  

<script>  
    import nestedCom from './nestedCom.vue'  
    export default {  
        props:['zhang'],  
        components:{  
            nestedCom  
        },  
        data(){  
            return {  
                nm:''  
            }  
        },  
        mounted(){  
            this.nm = this.zhang.originalProperty;  
            console.log(this.nm)  
        }  
    }  
</script>  

<style>  
    .fatherCom{  
        width: 200px;  
        height:200px;  
        background:#007AFF  
    }  
</style>  
<template>  
    <view class='nest'>这是NESTEDCOM----{{nm?nm:'无数据'}}</view>  
</template>  

<script>  
    export default {  
        props:['nm'],  
        data(){  
            return {  

            }  
        },  
        mounted(){  

        }  
    }  
</script>  

<style>  
    .nest{  
        width:100px;  
        height:100px;  
        background:green  
    }  
</style>  
function Person(name,age){  
    this.name = name;  
    this.age = age;  
    this.action= function(){  
        console.log('walk')  
    }  
}  
Person.prototype.originalProperty = 'Humanbeing'  
export default Person
2020-01-17 12:18 负责人:无 分享
已邀请:
飞墨悬云

飞墨悬云 (作者) - 前端

不知道是不是小程序本身就不支持这种参数传递的情况

一个前端er丶

一个前端er丶

你好,我现在也出现这种情景,请问你是怎么解决的呢?

该问题目前已经被锁定, 无法添加新回复