Skip to content
| Marketplace
Sign in
Visual Studio Code>Snippets>Hap ExtensionNew to Visual Studio Code? Get it now.
Hap Extension

Hap Extension

hap

|
11,175 installs
| (1) | Free
Hap Extension
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

hap

IntelliSense

⇥指TAB键

Tag

1.在页面文件中,输入h-,提示快捷模板片段,支持的模板片段如下:

Trigger Content
h-app→ Creates a hap app
h-page→ Creates a hap page
h-import→ Creates a hap import
h-template→ Creates a hap template
h-style→ Creates a hap style
h-script→ Creates a hap script

示例

Trigger: h-import→

<import name='' src=''></import>

2.在<template>中,输入h-,提示支持的组件

示例

Trigger: h-div→

<div></div>

Attributes

在组件的开始标签中,输入空格键提示该组件支持的属性

示例

Trigger: <div

Emmet snippets

Style

示例

Trigger: h-font-weight→

font-weight: normal;

Import Module

导入模块的简写方式与文档中示例代码相同

示例

Trigger: h-@system.router→

Content:

import router from '@system.router'

Interface

接口的简写方式与文档中接口定义相同

示例

Trigger: h-storage.set→

Content:

storage.set({
  key: 'key',
  value: 'value',
  success: function (data) {
    console.info('success');
  },
  fail: function (data, code) {
    console.info('fail');
  },
  complete: function () {
    console.info('complete')
  }
})

由于框架支持系统分享和三方分享,为避免重名。接口如下:

Trigger: h-system.share.share→

Content:

share.share({
  type: 'text/html',
  data: '<b>bold</b>',
  success: function (data) {
    console.info('success')
  },
  fail: function (data, code) {
    console.info('fail')
  },
  cancel: function (data) {
    console.info('cancel')
  },
  complete: function () {
    console.info('complete')
  }
})

Trigger: h-service.share.share→

Content:

share.share({
  shareType: 0,
  title: 'title',
  summary: 'summary',
  imagePath: 'xxx/xxx/xxx/share.jpg',
  targetUrl: 'http://www.example.com',
  success: function (data) {
    console.info('success')
  },
  fail: function (data, code) {
    console.info('fail')
  },
  cancel: function () {
    console.info('cancel')
  }
})

Installation

npm install && npm run compile

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft