小编oli*_*007的帖子

使用变量反应动态导入不起作用

使用 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)

我尝试刷新浏览器缓存但没有任何变化。

javascript dynamic-import reactjs

3
推荐指数
1
解决办法
2629
查看次数

qweb t-if 在位置属性

我正在 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)

对不起我的英语不好。我正在学习它。

openerp qweb

2
推荐指数
1
解决办法
3693
查看次数

使用字符串创建PHP类实例到Symfony2

我需要将不同的对象实例化为同一个方法.我在这里找到了解决方案:

使用字符串创建PHP类实例

但是当我在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)

抱歉我的英语,我正在学习它.

php inheritance symfony

1
推荐指数
1
解决办法
3122
查看次数