imingyu / wxml-transformer

将微信小程序的wxml代码转换成js object或html片段
BSD 3-Clause "New" or "Revised" License
22 stars 7 forks source link

wxml标签内无属性时报错TypeError: Cannot convert undefined or null to object #1

Open songyazhao opened 6 years ago

songyazhao commented 6 years ago

node@8.11.1 wxml-transformer@0.1.2

复现步骤:

const wt = require('wxml-transformer')
wt.toHtml(`<view id="con">{{ 123 }}</view>`) // 没问题
wt.toHtml(`<view>{{ 123 }}</view>`) // 报下面的错
TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at elementToObject (D:\GitHubOther\Plz-shop\node_modules\wxml-transformer\dist\index.js:137:16)
    at D:\GitHubOther\Plz-shop\node_modules\wxml-transformer\dist\index.js:174:21
    at each (D:\GitHubOther\Plz-shop\node_modules\wxml-transformer\dist\index.js:12:13)
    at toObject (D:\GitHubOther\Plz-shop\node_modules\wxml-transformer\dist\index.js:173:5)
    at Object.toHtml (D:\GitHubOther\Plz-shop\node_modules\wxml-transformer\dist\index.js:274:22)
songyazhao commented 6 years ago

Please release a new version to NPM

npm publish .