如题,假设有如下代码:

<script setup>
import { computed } from 'vue'
const props = defineProps({
  widths: {
    type: String,
    default: '100%',
  }
})

//在函数中调用应使用 props.prop 的方式。
function getWidths(){
  console.log(props.widths);
}
</script>

//在 template 中直接调用即可
<template>
<div :style="{ width: widths }" />
</template>
(adsbygoogle = window.adsbygoogle || []).push({});