Answers:
我们需要调用可用的默认方法。
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig在您的构造函数参数中使用Use ,并设置class属性:$this->scopeConfig = $scopeConfig;
现在要获取配置值,只需使用
$this->scopeConfig->getValue('dev/debug/template_hints', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);创建一个用于在自定义模块的帮助器中获取配置值的函数。
public function getConfig($config_path)
{
    return $this->scopeConfig->getValue(
            $config_path,
            \Magento\Store\Model\ScopeInterface::SCOPE_STORE
            );
}
并在您想要的任何地方打电话,例如在test.phtml中
$moduleStatus = $this->helper('Customvendorname\Custommodulename\Helper\Data')->getConfig('sectionid/groupid/fieldid');在这样的块和帮助程序调用中:
 $this->_objectManager->create('Customvendorname\Custommodulename\Helper\Data')->getConfig('sectionid/groupid/fieldid');$this->_objectManager->create(...)应避免使用。
                    我已经使用以下方法来检索变量
if (empty($this->_data['welcome'])) {
        $this->_data['welcome'] = $this->_scopeConfig->getValue(
            'design/header/welcome',
            \Magento\Store\Model\ScopeInterface::SCOPE_STORE
        );
    }
    return $this->_data['welcome'];