markdown 后端为前端导出变量

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 后端为前端导出变量相关的知识,希望对你有一定的参考价值。

### Template engine:
Usually, we place it in script section of footer.
```js
<script type="application/json" data-from-backend>
    {
      "product_id": "{{ product.id }}",
      "user_address": "{{ userAddress }}"
    }
</script>
```


### JS code:
```js
const jsonObj = JSON.parse($('[data-from-backend]').html());
```

以上是关于markdown 后端为前端导出变量的主要内容,如果未能解决你的问题,请参考以下文章