Home  >  Article  >  Backend Development  >  php框架 - 请问thinkphp这种情况U函数怎么生成?

php框架 - 请问thinkphp这种情况U函数怎么生成?

WBOY
WBOYOriginal
2016-06-06 20:23:531247browse

<code>var id = 123;
XHR.open('get','{:U("shop/goods/type_del", array("id" => id))}',false);
</code>

这是js代码里面的,这个id是js的变量,我要怎么来生成url呢,感觉没有可能做到啊?

这种情况怎么办啊,U方法好像也无能为力了啊???

在线等高手解决?

U方法在JS的这种情况下是不是无能为力了啊!!!

回复内容:

<code>var id = 123;
XHR.open('get','{:U("shop/goods/type_del", array("id" => id))}',false);
</code>

这是js代码里面的,这个id是js的变量,我要怎么来生成url呢,感觉没有可能做到啊?

这种情况怎么办啊,U方法好像也无能为力了啊???

在线等高手解决?

U方法在JS的这种情况下是不是无能为力了啊!!!

{:U("shop/goods/type_del")?id=}id

这个只能自己拼凑了,或者看着不爽,就用js写个U方法相似的功能出来,记得以前的thinksns就是写了一个U方法...不过还是不太灵活

<code>var id = 123;
XHR.open('get','{:U("shop/goods/type_del")}?id='+id,false);</code>

这个只能自己拼凑,模板引擎编译的时候,id都还没赋值呢。

<code class="js">U("shop/goods/type_del")+'?id='+id</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn