由于微信小程序的代码较长,我将为您提供一个简单的示例,您可以根据这个示例进行扩展和修改。 1. 首先,在微信开发者工具中创建一个新的小程序项目。 2. 在项目的根目录下创建一个名为`pages`的文件夹,然后在该文件夹下创建三个页面文件:`index`、`story1`和`story2`。每个页面文件包含以下内容: - `index.wxml`(首页): ```html <view class="container"> <view class="title">中国故事</view> <navigator class="link" open-type="navigate" target="miniProgram" app-id="your_app_id" path="pages/story1/story1"> <text>故事1</text> </navigator> <navigator class="link" open-type="navigate" target="miniProgram" app-id="your_app_id" path="pages/story2/story2"> <text>故事2</text> </navigator> </view> ``` - `index.wxss`(首页): ```css .container { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; } .title { font-size: 36rpx; font-weight: bold; margin-bottom: 40rpx; } .link { width: 200rpx; height: 80rpx; line-height: 80rpx; background-color: #1aad19; color: #ffffff; text-align: center; border-radius: 10rpx; margin-bottom: 20rpx; } ``` - `index.js`(首页): ```javascript Page({ data: {}, }); ``` - `story1.wxml`(故事1页面): ```html <view class="container"> <view class="title">故事1</view> <text class="content">这里是故事1的内容...</text> </view> ``` - `story1.wxss`(故事1页面): ```css .container { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; } .title { font-size: 36rpx; font-weight: bold; margin-bottom: 20rpx; } .content { font-size: 28rpx; color: #333333; line-height: 44rpx; } ``` - `story1.js`(故事1页面): ```javascript Page({ data: {}, }); ``` - `story2.wxml`(故事2页面): ```html <view class="container"> <view class="title">故事2</view> <text class="content">这里是故事2的内容...</text> </view> ``` - `story2.wxss`(故事2页面): ```css .container { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; } .title { font-size: 36rpx; font-weight: bold; margin-bottom: 20rpx; } .content { font-size: 28rpx; color: #333333; line-height: 44rpx; } ``` - `story2.js`(故事2页面): ```javascript Page({ data: {}, }); ``` 3. 在`app.json`文件中配置页面路径: ```json { "pages": [ "pages/index/index", "pages/story1/story1", "pages/story2/story2" ], "window": { "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#fff", "navigationBarTitleText": "中国故事", "navigationBarTextStyle": "black" } } ``` 现在,您可以在微信开发者工具中预览和调试您的小程序了。请根据您的需求修改页面内容和样式。 [2024-06-15 22:27:31 | AI写代码神器 | 1101点数解答]