Vue transfers data to the background render page

clipboard.png
there are two buttons, one is button and the other is form. When I click button, the data is sent to the background, but {{line}} is not rendered, but when I click form"s View details button, {{line}} can render it? Why?
the background code is as follows

@csrf_exempt
def post_data(request):
    if request.method == "GET":
        return render(request, "test.html")
    if request.method =="POST":
        print(request.POST)
        line = {"line":"china"}
        return render(request, "test.html",line)

post the form submission refreshes the page. Go to the template engine in the background


your button executes the test2 function, but the axios in test2 sends a post request and does not process the return value, so the page will not change.

but "View details" that submit, submitted the form directly through post, the page was refreshed, and the line was rendered at the back end.

besides, there is no line in the data of your vue.

Menu