呈现或评估动态标签字符串

时间:2020-10-09 09:46:51

标签: react-native

我希望在后端存储一些内容,其中包含带有样式的标记组件的混合。当呈现以下内容时,我只是得到'>“ Hello World”作为输出,而不是“ Hello World”。

from django.shortcuts import render
from django.contrib.auth.decorators import login_required
from .models import Project

@login_required(login_url='/accounts/login/')
def projectsWorkers(request):
  user = request.user
  user_projects = Project.objects.filter(worker=user).order_by('deadline')
  template = 'projects/projects-worker-home.html'
  return render(request, template, {'user_projects': user_projects, 'user': user})

如何将标记字符串呈现或评估为代码?

1 个答案:

答案 0 :(得分:0)

这可能有帮助

let fromDb = '<Text style={{color:"#f00"}}>Hello World</Text>';

return (
        <View style={styles.container}>
          {fromDb}             
        </View>
    )