欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2022-03-30 09:29:14
1,设置Emmet的补全快捷键首先确认你已经安装了Emmet插件打开 Sublime Text,依次点击: Sublime Text -> Preferences -> Package Settings -> Emmet -> Key Bindings - User,然后将下列内容粘贴到打开的文件中。[{ "keys": [ "super+e" ], "args": { "action": "expand_abbreviation"...

1,设置Emmet的补全快捷键

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

[
	{
	  "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,操作完成后目录结构如下图所示。
Mac下Sublime Text的Emmet无法补全React代码
经过以上几个步骤后,我的 Sublime Text 成功使用 Tab键补全React代码。

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