使用 React,谁能解释一下为什么当我们使用变量时动态导入会失败?
// Do not work
let module = "./DynamicComponent";
import(module).then(ModuleLoaded => {})
Run Code Online (Sandbox Code Playgroud)
// Works
import("./DynamicComponent").then(ModuleLoaded => {})
Run Code Online (Sandbox Code Playgroud)
我尝试刷新浏览器缓存但没有任何变化。
我正在 Odoo 中开发一个模块。我需要更改发票报告以添加一些详细信息。
我使用带有位置属性的 xpath 并检查是否链接了一个事件来隐藏默认表。
<template id="my_invoice" inherit_id="account.report_invoice_document">
<xpath expr="//div[@class='page']/table[@class='table table-condensed']" position="attributes">
<attribute t-if="o.affair_id" name="class">hidden</attribute>
</xpath>
</template>
Run Code Online (Sandbox Code Playgroud)
这是行不通的。即使发票未链接到事务,默认表也隐藏在每个发票中。
我不明白,因为条件适用于我的第二个模板。
<template id="my_invoice2" inherit_id="account.report_invoice_document">
<xpath expr="//div[@class='page']/div[@class='row mt32 mb32']" position="after">
<t t-if="o.affair_id">
<!-- table with my additional detail -->
</t>
</xpath>
</template>
Run Code Online (Sandbox Code Playgroud)
对不起我的英语不好。我正在学习它。
我需要将不同的对象实例化为同一个方法.我在这里找到了解决方案:
但是当我在Controller of Symfony2上使用它时,我有这个错误:
尝试从全局命名空间加载类"PhotoType".你忘记了"使用"声明吗?
我不明白,因为我添加了所有"使用"
namespace DIVE\FileUploaderBundle\Controller;
use DIVE\FileUploaderBundle\Entity\Photo;
use DIVE\FileUploaderBundle\Form\PhotoType;
...
class DefaultController extends Controller {
public function listFileAction($fileType) {
$em = $this->getDoctrine()->getManager();
$repository = $em->getRepository("FDMFileUploaderBundle:".$fileType);
$files = $repository->findAll();
$forms = array();
foreach ($files as $file) {
$class = $fileType."Type";
array_push($forms, $this->get('form.factory')->create(new $class(), $file));
}
$formViews = array();
foreach ($forms as $form) {
array_push($formViews, $form->createView());
}
return $this->render("FDMFileUploaderBundle:Default:list".$fileType.".html.twig", array(
"forms" => $formViews
)
);
}
}
Run Code Online (Sandbox Code Playgroud)
抱歉我的英语,我正在学习它.