uni-app模板的导入简单案例

    技术2023-09-21  110

    pages.json文件

    { "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages { "path": "pages/index/index", "style": { "navigationBarTitleText": "uni-app" } } ], "globalStyle": { "navigationBarTextStyle": "black", "navigationBarTitleText": "uni-app", "navigationBarBackgroundColor": "#F8F8F8", "backgroundColor": "#F8F8F8" } }

    /pages/index/inde.vue

    <template> <view> test页面 <br> <test :text="text"></test> </view> </template> <script> import test from "../../components/test/test.vue"; export default{ comments:{ test }, data(){ return { 'text': '父亲组件传给子组件的text变量数据' } } } </script> <style> view{ font-size: 10px; } </style>

    /components/test/test.vue

    <template> <view> 这是需要导入的模板 <br> 接收父组件的数据--------{{text}} </view> </template> <script> export default{ props:{ text: String } } </script> <style> view { font-size: 10px; } </style>

    运行结果:

    Processed: 0.008, SQL: 9