暂存代码区

 News.vue

<template>  
    <view>  
        <view v-for="(news, index) in newsList" :key="news.id" @click="navigateToDetail(news)">  
            {{ news.content }}  
        </view>  
        <!-- <view>
          <Detail :parent-data = "newslist"></Detail>
        </view> -->
    </view>  
</template>  

<script setup lang="ts">
import{reactive} from 'vue'
    const newsList = reactive
    (
        [
            {
                id:1,content:"清华",time:"1622"
            },
            {
                id:2,content:"北大",time:"1623"
            },
            {
                id:3,content:"北理工",time:"1624"
            }
        ]
    )
    function switchTabDetail(news: { id: any; content: any; time: any; }) 
    {  
        uni.switchTab
        ({  
            url: `/pages/Detail?id=${news.id}&content=${news.content}&time=${news.time}`  
        });  
    }  
</script>

Detail.vue

<template>
  <view>
    <ul class="news-list">
      <li>编号:{{id}}</li>
      <li>内容:{{content}}</li>
      <li>标题:{{time}}</li>
    </ul>
  </view>
</template>


<script setup lang="ts">  
import { onMounted, ref } from 'vue'  
  
const id = ref('')  
const content = ref('')  
const time = ref('')  
  
onMounted(() => 
{  
    const pages = getCurrentPages();  
    const currentPage = pages[pages.length - 1];  
    const options = currentPage.options;  
    id.value = options.id;  
    content.value = options.content;  
    time.value = options.time;  
})  
</script>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值