import './index.css' import avatar from './images/avatar.png' // 依赖的数据 const state = { // hot: 热度排序 time: 时间排序 tabs: [ { id: 1, name: '热度', type: 'hot' }, { id: 2, name: '时间', type: 'time' } ], active: 'hot', list: [ { id: 1, author: '刘德华', comment: '给我一杯忘情水', time: new Date('2021-10-10 09:09:00'), // 1: 点赞 0:无态度 -1:踩 attitude: 1 }, { id: 2, author: '周杰伦', comment: '哎哟,不错哦', time: new Date('2021-10-11 09:09:00'), // 1: 点赞 0:无态度 -1:踩 attitude: 0 }, { id: 3, author: '五月天', comment: '不打扰,是我的温柔', time: new Date('2021-10-11 10:09:00'), // 1: 点赞 0:无态度 -1:踩 attitude: -1 } ] } // 格式化时间文本 function getTime (time) { return `${time.getFullYear()}-${time.getMonth() + 1}-${time.getDate()}` } function App () { return (
{/* 评论数 */}
5 评论
{/* 排序 */}
    {state.tabs.map(item =>
  • 按{item.name}排序
  • )}
{/* 添加评论 */}