How to use the @tarojs/shared.capitalize function in @tarojs/shared

To help you get started, we’ve selected a few @tarojs/shared examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NervJS / taro / packages / taro-mini-runner / src / template / index.ts View on Github external
return [...attrs].reduce((str, attr) => {
    if (attr.startsWith('@')) { // vue event
      if (Adapter.type === BUILD_TYPES.ALIPAY) {
        return str + `on${capitalize(attr.slice(1))}="eh" `
      }
      return str + `bind${attr.slice(1)}="eh" `
    } else if (attr.startsWith('bind')) {
      return str + `${attr}="eh" `
    } else if (attr.startsWith('on')) {
      if (Adapter.type === BUILD_TYPES.ALIPAY) {
        return str + `${attr}="eh" `
      }

      return str + `bind${attr.slice(2).toLowerCase()}="eh" `
    }

    return str + `${attr}="{{ i.${attr} }}" `
  }, '')
}