uniapp+Django实现点击收藏按钮变色

本文介绍了如何使用uniapp结合Django实现点击收藏按钮时,按钮颜色根据收藏状态变化的功能。在uniapp端,通过@click事件传递内容到后端判断收藏状态。在Django端,接收到内容和用户信息,处理用户与条目的多对多关系,收藏时建立关联,取消收藏时解除关联,同时更新星星颜色表示收藏状态。
摘要由CSDN通过智能技术生成

uniapp

收藏与取消收藏:就是点击这个:@click="store(item.content,item.star_style)"

通过点击的item.content传给后端判断当前点击的这条目是什么

展示星星的颜色与条目信息是在onload函数里的。

<template>
	<view class="flex-col page">
	  <view class="flex-col group">
	    <view class="justify-between section_1" @click="toPost">
	      <text class="text">发帖</text>
	      <image
	        src="https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/621b3ba25a7e3f031094e05a/6263de904eb5590011d34380/16507122302491358008.png"
	        class="image"
	      />
	    </view>
	    <view class="flex-row group_1">
	      <image
	        src="https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/621b3ba25a7e3f031094e05a/6263de904eb5590011d34380/16514940693480572865.png"
	        class="image_1"
	      />
	      <view class="flex-col items-center text-wrapper">
	        <text>就近帮扶</text>
	      </view>
	    </view>
	    <view class="flex-col group_2">
	      <view class="flex-col section_2">
			<view v-for="item in items" >
				<text class="text_2">{
  {item.content}}</text>
				<view class="justify-between group_4">
				  <image
					:src=item.star_style
				    class="image_3 image_4"
					@click="store(item.content,item.star_style)"
				  />
				  <view class="flex-row">
				    <view class="left
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值