我想在一行下面输入以下内容。有可能吗?
`import SellerAdaptor from '../adaptors/sellers';
import UserAdaptor from '../adaptors/user';
import ShopEarnAdaptor from '../adaptors/shop_earn';
import ProductAdaptor from '../adaptors/product';
import JobAdaptor from '../adaptors/job';
import OrderAdaptor from '../adaptors/order';
import NotificationAdaptor from '../adaptors/notification';
import CategoryAdaptor from '../adaptors/category';
import AdminAdaptor from '../adaptors/adminAdaptor';`
答案 0 :(得分:6)
否。
解构将使您可以从一个模块中导入许多值。
您不能一次导入多个模块。
典型的模式是使用../adaptors/index
导入所有模块,然后导出它们:
import SellerAdaptor from './sellers';
import UserAdaptor from './user';
// etc
export { SellerAdaptor, UserAdaptor, etc };
那么您将能够:
import { SellerAdaptor, UserAdaptor, etc } from "../adaptors/index";
答案 1 :(得分:0)
要能够写<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:output
method="xml"
encoding="UTF-8"
indent="yes"/>
<xsl:template match="/">
<xsl:for-each select="root/row[name='name1'] | root/row[name='name2']">
<xsl:variable name="filename" select="concat('output/',name,'.xml')" />
<xsl:result-document href="{$filename}" method="xml" encoding="iso-8859-1">
<xsl:for-each select="/">
<xsl:element name="topic">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
</xsl:result-document>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
,它要放在import { A, B, C } from 'myPackage'
上,并且要如何写。
如果它们是不同的文件,则无法执行。
如果您有一个myPackage
文件adaptors
,其中包含export
个不同的模块,则可以使用解构来编写导入文件。
答案 2 :(得分:0)
您可以执行以下操作:
import SellerAdaptor from '../adaptors/sellers';
import UserAdaptor from '../adaptors/user';
import ShopEarnAdaptor from '../adaptors/shop_earn';
import ProductAdaptor from '../adaptors/product';
import JobAdaptor from '../adaptors/job';
import OrderAdaptor from '../adaptors/order';
import NotificationAdaptor from '../adaptors/notification';
import CategoryAdaptor from '../adaptors/category';
import AdminAdaptor from '../adaptors/adminAdaptor';
export {
SellerAdaptor,
UserAdaptor,
ShopEarnAdaptor,
ProductAdaptor,
JobAdaptor,
OrderAdaptor,
NotificationAdaptor,
CategoryAdaptor,
AdminAdaptor
}
然后您可以按如下所示导入
import { SellerAdaptor, UserAdaptor} from './<filename>'