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

1,设置Emmet的补全快捷键

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

[{
  "keys": [
    "ctrl+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, 
        "key": "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代码。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值