style h1{ color: red; text-align: center; } /style /head body ng-init=user={name:tom,age:20,work。如何进行网页数据抓取与绑定( 二 )。" />

如何进行网页数据抓取与绑定( 二 )


<link rel="stylesheet" href=https://vvvtt.com/article/"node_modules/bootstrap/dist/css/bootstrap.min.css">
<style>
h1{
color: red;
text-align: center;
}
</style>

</head>
<body ng-init="user={name:'tom',age:20,work:'前端开发工程师'}">
<h1>{{user.name}}</h1>
<h1>{{user.age}}</h1>
<h1>{{user.work}}</h1>
<script src=https://vvvtt.com/article/"node_modules/bootstrap/dist/js/bootstrap.min.js">
<script src=https://vvvtt.com/article/"node_modules/angular/angular.min.js">
</body>
</html>

如何进行网页数据抓取与绑定

文章插图

07 运行程序 。

如何进行网页数据抓取与绑定

文章插图

08 用(ng-bind)进行绑定 。 例:创建一条数据 , 内容包括用户名 , 年龄 , 职业等;要求字体大小为18px,居中对齐 , 代码如下:
<!DOCTYPE html>
<html lang="en" ng-app>
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href=https://vvvtt.com/article/"node_modules/bootstrap/dist/css/bootstrap.min.css">
<style>
*{
text-align: center;
}
a{
font-size: 18px;
color: red;
}
</style>
</head>
<body ng-init="user={name:'李雷',age:20,work:'前端开发工程师'}">
<a href=https://vvvtt.com/article/"" ng-bind="user.name">
<a href=https://vvvtt.com/article/"" ng-bind="user.age">
<a href=https://vvvtt.com/article/"" ng-bind="user.work">
<script src=https://vvvtt.com/article/"node_modules/bootstrap/dist/js/bootstrap.min.js">
<script src=https://vvvtt.com/article/"node_modules/angular/angular.min.js">
</body>
</html><html lang="en" ng-app>
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href=https://vvvtt.com/article/"node_modules/bootstrap/dist/css/bootstrap.min.css">
<style>
*{
text-align: center;
}
a{
font-size: 18px;
color: red;
}
</style>
</head>
<body ng-init="user={name:'李雷',age:20,work:'前端开发工程师'}">
<script src=https://vvvtt.com/article/"node_modules/bootstrap/dist/js/bootstrap.min.js">
<script src=https://vvvtt.com/article/"node_modules/angular/angular.min.js">
</body>
</html>

如何进行网页数据抓取与绑定

文章插图

09 创建三个超链接 , 分别用(ng-bind)提取并绑定数据 , 绑定的数据 , 代码如下:
<!DOCTYPE html>
<html lang="en" ng-app>
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href=https://vvvtt.com/article/"node_modules/bootstrap/dist/css/bootstrap.min.css">
<style>
*{
text-align: center;
}
a{
font-size: 18px;
color: red;
}
</style>
</head>
<body ng-init="user={name:'李雷',age:20,work:'前端开发工程师'}">
用户名:<a href=https://vvvtt.com/article/"" ng-bind="user.name">

推荐阅读