在原生小程序中,想要实现自动换行可以直接在css中进行设置
增加一下css style即可:
{
word-break:normal;
word-wrap:break-word;
display:-webkit-box;
-webkit-line-clamp:2;
overflow:hidden;
-webkit-box-orient: vertical;
}
但是在Taro3.x版本的css文件编译中,会省略-webkit-box-orient属性的编译。
如果想要实现多行文本自动换行溢出部分省略的效果,-webkit-box-orient 需要写在style中,如下
<View className='articleTitle' style={{"-webkit-box-orient": "vertical"}}>{item.title}{item.title} </View>
Taro的导航栏引入需要在页面的config中定义navigationStyle为custom,并在usingComponent中引入自定义组件
homepage.config = {
navigationStyle: "custom",
usingComponents: {
"nav-bar": "../../components/nav-bar/nav-bar",
"van-sticky": "../../components/vant/dist/sticky/index",
}
}