我有一个非SPA网络应用程序,其中包含Vue组件,并且非常有用.但是,我正在寻找一种方法来加载包含Vue通过外部API的HTML .
所以,我只是调用/ajax/dialogbox/client/add返回包含Vue组件的HTML ,例如:
<h1>Add client</h1>
<div>My static content</div>
<my-component></my-component>
Run Code Online (Sandbox Code Playgroud)
但显然<my-component></my-component>什么也没做.在Angular 1我使用$compile的服务来编译输出之前的HTML.
有没有办法做同样的事情Vue?
我将JSON数据发布到控制器中的表单.实体没有填写我发送的属性,这里是它的样子:
// Controller
class UserApiController extends FOSRestController
{
// works fine
public function cgetAction()
{
return $this->get('model.user')->getAllUsers();
}
// works fine
public function getAction($id)
{
return $this->get('model.user')->getUserById($id);
}
// this method fails
public function postAction(Request $request)
{
$form = $this->createForm(new UserType(), new User());
$form->bind($request);
if($form->isValid())
{
die('are you valid or not??');
}
return $this->view($form, 400);
}
}
Run Code Online (Sandbox Code Playgroud)
实体看起来像常规实体,也可以形成.
我有一个测试控制器将json数据发送到api:
public function testJsonPostAction()
{
$client = static::createClient();
$client->request(
'POST',
'/api/1.0/users',
array(),
array(),
array('CONTENT_TYPE' => 'application/json'),
'{"firstName": "John", "lastName": "Doe", "emailAddress": "something@somewhere.com", …Run Code Online (Sandbox Code Playgroud)