我遇到一個問題,當我嘗試瀏覽新模塊時找不到它。這是代碼的詳細信息。Ced/CsTermsAndServices/etc/Module.xml<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <module name="Ced_TermsAndServices" setup_version="1.0.0"> </module></config>Ced/CsTermsAndServices/registration.php<?PHP \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'Ced_TermsAndServices', __DIR__ );Ced/CsTermsAndServices/etc/frontend/routes.xml<?xml version="1.0" ?><config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd"> <router id="standard"> <route frontName="cstermsandservices" id="cstermsandservices"> <module name="Ced_TermsAndServices"/> </route> </router></config>Ced/CsTermsAndServices/Controller/Index/Index.php<?phpnamespace Ced\CsTermsAndServices\Controller\Index;class Index extends \Magento\Framework\App\Action\Action{ protected $_pageFactory; public function __construct( \Magento\Framework\App\Action\Context $context, \Magento\Framework\View\Result\PageFactory $pageFactory) { $this->_pageFactory = $pageFactory; return parent::__construct($context); } public function execute() { echo "Hello World"; exit; }}預期的路線應該是 http://localhost/cstermsandservices/index/index但結果卻是404 not found。有什么解決辦法嗎?
1 回答

蕪湖不蕪
TA貢獻1796條經驗 獲得超7個贊
1)確保遵循供應商/模塊名稱供應商模塊名稱約定(在您的情況下,如果您想遵循當前目錄結構,模塊名稱應為Ced_CsTermsAndServices)2)module.xml文件名應全部小寫
希望這能成功 Magento 快樂
- 1 回答
- 0 關注
- 134 瀏覽
添加回答
舉報
0/150
提交
取消