this.param

您可以通过this.param访问当前的URL参数,它返回一个PHP数组。

访问页面参数

此示例演示如何访问页面中的“tab”URL参数。

  1. url = "/account/:tab"
  2. ==
  3. {% if this.param.tab == 'details' %}
  4. <p>Here are all your details</p>
  5. {% elseif this.param.tab == 'history' %}
  6. <p>You are viewing a blast from the past</p>
  7. {% endif %}

如果参数名称也是变量,则可以使用数组语法。

  1. url = "/account/:post_id"
  2. ==
  3. {% set name = 'post_id' %}
  4. <p>The post ID is: {{ this.param[name] }}</p>