问题解决:微信小程序编译后出现unexpected attribute name, near `.for`/`.key`/的等一系列unexpected attribute name, near问题

问题:

当对初始代码添加了wx.forwx.key

初始代码
  <view class="tab">
    <van-button round type="info" class="tab-item" size="small">豆子</van-button>
  </view>

最后代码
  <view class="tab">
    <van-button wx.for="{{tab_list}}" wx.key="index" round type="info" class="tab-item" size="small">{{item.title}}</van-button>
  </view>

添加wx.forwx.key后的最后代码,保存编译出现的错误:

[ WXML 文件编译错误] ./pages/home/index.wxml
 unexpected attribute name, near `.for`
   9 |   </swiper>
  10 |   <view class="tab">
> 11 |     <van-button wx.for="{{tab_list}}" wx.key="index" round type="info" class="tab-item" size="small">{{item.title}}</van-button>
     |                  ^
  12 |   </view>
  13 | </view>
at files://pages/home/index.wxml#11(env: Windows,mp,1.06.2303220; lib: 2.32.0)
[ WXML 文件编译错误] ./pages/home/index.wxml

删除wx.for后出现的错误:

[自动热重载错误 WXML 文件编译错误] ./pages/home/index.wxml
 unexpected attribute name, near `.key`
   9 |   </swiper>
  10 |   <view class="tab">
> 11 |     <van-button wx.key="index" round type="info" class="tab-item" size="small">{{item.title}}</van-button>
     |                  ^
  12 |   </view>
  13 | </view>
at files://pages/home/index.wxml#11(env: Windows,mp,1.06.2303220; lib: 2.32.0)


原因:

WXML 文件编译错误,组件未被编译

解决:

wx.for应该改成wx:forwx.key应该改成wx:key

更改后:

  <view class="tab">
    <van-button wx:for="{{tab_list}}" wx:key="index" round type="info" class="tab-item" size="small">{{item.title}}</van-button>
  </view>

编译正常

一系列的unexpected attribute name, near问题原因:

一系列的unexpected attribute name, near…问题,都是 WXML 文件编译错误,组件未被编译,那么就需要好好查查自己敲得代码,看看哪里出错,下面举一些例子(源自腾讯的wepy—小程序支持组件化开发的框架的issue

  • 1. 报unexpected attribute name near .sync
    • import CouponList from '../components/couponList.wpy' 中多了文件后缀.wpy,去掉后缀后import CouponList from '../components/couponList'

*******************

    • components = {}改成components: {}

*******************

    • 确保你的自定义标签没有下划线或者驼峰的形式,全单字符、字母全小写

*******************

    • 确保你的自定义标签没有下划线或者驼峰的形式,全单字符、字母全小写

*******************

  • 4.报unexpected attribute name, near \\`.once\`
    • <input type="text" :value="msg" />.wpy文件转换成.wxml<input type="text" v-bind:value.once="msg"/> 。这里不支持 :value 属性,要 value=“{{msg}}”。
D:\桌面\OJ项目\douoj>npm run generate-api > douoj@0.1.0 generate-api > openapi-generator-cli generate -i http://localhost:8121/api/v2/api-docs -g typescript-axios -o ./generated --additional-properties=supportsES6=true Picked up JAVA_TOOL_OPTIONS: -Dstdout.encoding=UTF-8 -Dstderr.encoding=UTF-8 Exception in thread "main" org.openapitools.codegen.SpecValidationException: There were issues with the specification. The option can be disabled via validateSpec (Maven/Gradle) or --skip-validate-spec (CLI). | Error count: 50, Warning count: 0 Errors: -attribute paths.'/api/post/list/page/vo'(post).responsesObject is unexpected -attribute paths.'/api/user/get'(get).responsesObject is unexpected -attribute paths.'/api/post/list/page'(post).responsesObject is unexpected -attribute paths.'/api/post/edit'(post).[postEditRequest].originalRef is unexpected -attribute paths.'/api/user/update'(post).responsesObject is unexpected -attribute paths.'/api/post_favour/'(post).responsesObject is unexpected -attribute paths.'/api/user/list/page/vo'(post).[userQueryRequest].originalRef is unexpected -attribute paths.'/api/user/register'(post).responsesObject is unexpected -attribute paths.'/api/post_favour/list/page'(post).responsesObject is unexpected -attribute paths.'/api/post/add'(post).responsesObject is unexpected -attribute paths.'/api/post/edit'(post).responsesObject is unexpected -attribute paths.'/api/post_favour/my/list/page'(post).responsesObject is unexpected -attribute paths.'/api/user/update/my'(post).[userUpdateMyRequest].originalRef is unexpected -attribute paths.'/api/post_favour/my/list/page'(post).[postQueryRequest].originalRef is unexpected -attribute paths.'/api/post/update'(post).responsesObject is unexpected -attribute paths.'/api/post_thumb/'(post).responsesObject is unexpected -attribute paths.'/api/post_favour/'(post).[postFavourAddRequest].originalRef is unexpected -attribute paths.'/api/user/login'(post).responsesObject is unexpected -attribute paths.'/api/user/add'(post).responsesObject is unexpected -attribute paths.'/api/post/list/page/vo'(post).[postQueryRequest].originalRef is unexpected -attribute paths.'/api/user/list/page'(post).responsesObject is unexpected -attribute paths.'/api/user/delete'(post).responsesObject is unexpected -attribute paths.'/api/post/search/page/vo'(post).responsesObject is unexpected -attribute paths.'/api/'(post).responsesObject is unexpected -attribute paths.'/api/file/upload'(post).responsesObject is unexpected -attribute paths.'/api/post/list/page'(post).[postQueryRequest].originalRef is unexpected -attribute paths.'/api/user/add'(post).[userAddRequest].originalRef is unexpected -attribute paths.'/api/post/my/list/page/vo'(post).[postQueryRequest].originalRef is unexpected -attribute paths.'/api/post/get/vo'(get).responsesObject is unexpected -attribute paths.'/api/user/login'(post).[userLoginRequest].originalRef is unexpected -attribute paths.'/api/post_thumb/'(post).[postThumbAddRequest].originalRef is unexpected -attribute paths.'/api/setMenu'(get).responsesObject is unexpected -attribute paths.'/api/user/login/wx_open'(get).responsesObject is unexpected -attribute paths.'/api/user/register'(post).[userRegisterRequest].originalRef is unexpected -attribute paths.'/api/user/update/my'(post).responsesObject is unexpected -attribute paths.'/api/post/add'(post).[postAddRequest].originalRef is unexpected -attribute paths.'/api/user/logout'(post).responsesObject is unexpected -attribute paths.'/api/post/update'(post).[postUpdateRequest].originalRef is unexpected -attribute paths.'/api/'(get).responsesObject is unexpected -attribute paths.'/api/user/list/page/vo'(post).responsesObject is unexpected -attribute paths.'/api/post/delete'(post).[deleteRequest].originalRef is unexpected -attribute paths.'/api/user/get/vo'(get).responsesObject is unexpected -attribute paths.'/api/user/get/login'(get).responsesObject is unexpected -attribute paths.'/api/post/search/page/vo'(post).[postQueryRequest].originalRef is unexpected -attribute paths.'/api/post/my/list/page/vo'(post).responsesObject is unexpected -attribute paths.'/api/post_favour/list/page'(post).[postFavourQueryRequest].originalRef is unexpected -attribute paths.'/api/user/delete'(post).[deleteRequest].originalRef is unexpected -attribute paths.'/api/post/delete'(post).responsesObject is unexpected -attribute paths.'/api/user/update'(post).[userUpdateRequest].originalRef is unexpected -attribute paths.'/api/user/list/page'(post).[userQueryRequest].originalRef is unexpected at org.openapitools.codegen.config.CodegenConfigurator.toContext(CodegenConfigurator.java:717) at org.openapitools.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:744) at org.openapitools.codegen.cmd.Generate.execute(Generate.java:527) at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32) at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
06-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值