当前位置: 移动技术网 > IT编程>开发语言>.net > Mac下Sublime Text的Emmet无法补全React代码

Mac下Sublime Text的Emmet无法补全React代码

2020年07月07日  | 移动技术网IT编程  | 我要评论

1,设置Emmet的补全快捷键

首先确认你已经安装了Emmet插件
打开 Sublime Text,依次点击: Sublime Text -> Preferences -> Package Settings -> Emmet -> Key Bindings - User,然后将下列内容粘贴到打开的文件中。打开设置

[
	{
	  "keys": [
	    "super+e"
	  ],
	  "args": {
	    "action": "expand_abbreviation"
	  },
	  "command": "run_emmet_action",
	  "context": [{
	      "key": "emmet_action_enabled.expand_abbreviation"
	    }]
	},{
      "keys": ["tab"], 
      "command": "expand_abbreviation_by_tab", 

      // put comma-separated syntax selectors for which 
      // you want to expandEmmet abbreviations into "operand" key 
      // instead of SCOPE_SELECTOR.
      // Examples: source.js, text.html - source
      "context": [
        {
          "operand": "source.js", 
          "operator": "equal", 
          "match_all": true, 
          "key": "selector"
        }, 

        // run only if there's no selected text
        {
          "match_all": true, 
          "k": "selection_empty"
        },

        // don't work if there are active tabstops
        {
          "operator": "equal", 
          "operand": false, 
          "match_all": true, 
          "key": "has_next_field"
        }, 

        // don't work if completion popup is visible and you
        // want to insert completion with Tab. If you want to
        // expand Emmet with Tab even if popup is visible -- 
        // remove this section
        {
          "operand": false, 
          "operator": "equal", 
          "match_all": true, 
          "key": "auto_complete_visible"
        }, 
        {
          "match_all": true, 
          "key": "is_abbreviation"
        }
      ]
    }
]

将文件保存后重启 Sublime Text,此时编写 React 项目应该可以正常进行补全。但是我的Sublime在完成以上步骤后仍然不能补全,通过 ctrl + ` 调出Sublime 的控制台发现如下错误:AttributeError: ‘module’ object has no attribute 'JSContext。通过在网上查找资料发现是PyV8的问题,然后解决该问题。

2 解决 AttributeError: ‘module’ object has no attribute ‘JSContext’

第一步,下载PyV8,下载地址为:PyV8下载地址,选择对应操作系统的版本下载并解压。
第二步,将PyV8放到指定目录下,目录为:/Users/用户名/Library/Application Support/Sublime Text 3/Installed Packages,操作完成后目录结构如下图所示。
目录结构
经过以上几个步骤后,我的 Sublime Text 成功使用 Tab键补全React代码。

本文地址:https://blog.csdn.net/SwiftLess/article/details/107147498

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网