Sun May 21 16:19:00 UTC 2023 inscode

上级 e6cf4087
<script setup> <script setup>
import {ref} from 'vue'; import baVal = ref(0);
import erzi from './erzi.vue'; import erzi from './erzi.vue';
const babaMsg = ref("我来自父组件"); const fuValJia = () => {
baVal++;
}
</script> </script>
<template> <template>
<erzi :chuanBaba="babaMsg"></erzi> <button @click="fuValJia">父组件的值加一</button>
<erzi :title="baVal"></erzi>
</template> </template>
<style scoped> <style scoped>
......
<script setup> <script setup>
import {ref, toRefs, defineProps } from "vue"; const props = defineProps({
const getVal = defineProps({ title: {
chuanBaba: String, type:String,
default: "默认值"
}
}); });
const sss = toRefs(getVal); console.log(props.title);
</script> </script>
<template> <template>
<div> <div>
获取来自父组件的值:{{ sss }} 获取来自父组件的值:{{ title }}
</div> </div>
</template> </template>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册