2021-11-02

uniapp使用nvue页面文本换行

编码器+技术:HBuilderX + vue/NVue/uniapp/vuex

官网写法用rich-text

html代码

<rich-text class="rich-texts" :nodes="nodes"></rich-text>

js代码

export default{
	data(){
		return{
			nodes:[		// nvue页面css换行
					{
						name: 'span',
						children: [{
								type: 'text',
								attrs: { class: 'zhi_index09', },
								text: 'Tao少',
							},{
								name: 'span',
								children: [
									{
										attrs: { class: 'zhi_index10',},
										type: 'text',
										text: '回复',
									},
								],
							},{
								name: 'span',
								attrs: { class: 'zhi_index09',},
								children: [
									{
										type: 'text',
										text: 'Tao少'+ ':',
									},
								],
							},{
								name: 'span',
								attrs: { class: 'zhi_index10',},
								children: [
									{
										type: 'text',
										text: '这里是用户1的回复内',
									},
								],
							}],
					},
				]
		}
	}
}

css代码

<style scopde>
.zhi_index09 {line-height: 50upx;color: #00AAFF;font-size: 30rpx;font-weight: bold;line-height:35rpx; }
	.zhi_index10 {line-height: 50upx;font-size: 30rpx;color:#2a2a2a;line-height:35rpx;}
</style>

效果图

在这里插入图片描述

这样基本就完成了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
生产者消费者问题是一个经典的同步问题,其中生产者和消费者共享一个缓冲区,生产者向缓冲区中生产产品,消费者从缓冲区中消费产品。在多线程的环境下,生产者和消费者可能会同时访问缓冲区,因此需要对缓冲区进行同步控制。 以下是一个简单的生产者消费者问题的实现: ```c #include <stdio.h> #include <stdlib.h> #include <pthread.h> #define BUFFER_SIZE 10 int buffer[BUFFER_SIZE]; int count = 0; int in = 0; int out = 0; pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t empty = PTHREAD_COND_INITIALIZER; pthread_cond_t full = PTHREAD_COND_INITIALIZER; void *producer(void *arg) { int i; for (i = 0; i < 20; i++) { pthread_mutex_lock(&mutex); while (count == BUFFER_SIZE) { pthread_cond_wait(&empty, &mutex); } buffer[in] = i; in = (in + 1) % BUFFER_SIZE; count++; printf("producer: produced %d\n", i); pthread_cond_signal(&full); pthread_mutex_unlock(&mutex); } pthread_exit(NULL); } void *consumer(void *arg) { int i, data; for (i = 0; i < 20; i++) { pthread_mutex_lock(&mutex); while (count == 0) { pthread_cond_wait(&full, &mutex); } data = buffer[out]; out = (out + 1) % BUFFER_SIZE; count--; printf("consumer: consumed %d\n", data); pthread_cond_signal(&empty); pthread_mutex_unlock(&mutex); } pthread_exit(NULL); } int main() { pthread_t tid1, tid2; pthread_create(&tid1, NULL, producer, NULL); pthread_create(&tid2, NULL, consumer, NULL); pthread_join(tid1, NULL); pthread_join(tid2, NULL); return 0; } ``` 在代码中,我们定义了一个大小为10的缓冲区,使用一个计数器count来记录缓冲区中产品的数量,in和out分别表示生产者和消费者在缓冲区中的位置。我们使用了两个条件变量empty和full来控制生产者消费者的同步。 在生产者中,当缓冲区已满时,生产者会等待empty条件变量,直到缓冲区有空位。当生产者生产完一个产品后,会唤醒消费者,并释放互斥锁。 在消费者中,当缓冲区为空时,消费者会等待full条件变量,直到缓冲区有产品。当消费者消费完一个产品后,会唤醒生产者,并释放互斥锁。 通过使用互斥锁和条件变量,我们可以保证生产者和消费者的正确同步,避免了竞争条件和死锁等问题。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值